/*我知道自己的函数名很好看……*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
string s1,s2;
void o_o(int la,int ra,int lb,int rb)
{
int m=s2.find(s1[la]);
if(m>lb)o_o(la+1,la+m+lb,lb,m-1);
if(m<rb)o_o(la+m-lb+1,ra,m+1,rb);
cout<<s1[la];
}
int main()
{
cin>>s1>>s2;
o_o(0,s1.length()-1,0,s2.length()-1);
return 0;
}