#include <iostream>
#include <string>
using namespace std;
string f(string zhong, string hou)
{
int i, num;
num=hou.size();
if (zhong == "") return "";
for (i=0; i<zhong.size(); i++) if (zhong[i] == hou[num-1]) break;
return hou[num-1] + f(zhong.substr(0, i-1), hou.substr(i, num-2)) + f(zhong.substr(0, i), hou.substr(i+1, num-2));
}
int main()
{
string zhong, hou;
cin>>zhong>>hou;
cout<<f(zhong, hou)<<endl;
return 0;
}