#include <bits/stdc++.h>
using namespace std;
char a[30],b[30],c[30];
int Al;
int qwe = 0;
void fd(int l,int r){
qwe++;
cout << c[r];
int point=0;
if(l == r)return;
for(int i = 0;i<=Al-1;i++){
if(b[i] == c[r]){
point = i;
break;
}
}
if(l < point){
bool x[3000]={0};
for(int i = l;i<point;i++){
for(int j = 0;j<Al;j++){
if(b[i] == c[j]){
x[j] = 1;
}
}
}
int st=-1,ed=-1;
bool hx = 0;
for(int i = 0;i<Al;i++){
if(hx == 0 && x[i] == 1){
hx = 1;
st = i;
}else if(hx == 1 && x[i] == 0){
hx = 0;
ed = i-1;
}
}
fd(st,ed);
}
if(r > point){
bool x[3000]={0};
for(int i = point+1;i<=r;i++){
for(int j = 0;j<Al;j++){
if(b[i] == c[j]){
x[j] = 1;
}
}
}
int st=-1,ed=-1;
bool hx = 0;
for(int i = 0;i<Al;i++){
if(hx == 0 && x[i] == 1){
hx = 1;
st = i;
}else if(hx == 1 && x[i] == 0){
hx = 0;
ed = i-1;
}
}
fd(st,ed);
}
}
int main(){
cin >> b >> c;
Al = strlen(b);
fd(0,Al-1);
}