#include <bits/stdc++.h>
using namespace std;
void getxx(string zx, string cx)
{
if (cx.size() == 0)
return;
char root = cx[0];
int id = zx.find(root);
string zxl = zx.substr(0, id), zxr = zx.substr(id + 1), cxl = "", cxr = "";
for (int i = 1; i < cx.size(); i++)
if (zxl.find(cx[i]) == string::npos)
cxr += cx[i];
else
cxl += cx[i];
cout << root;
getxx(zxl, cxl);
getxx(zxr, cxr);
}
int main()
{
string zx, cx;
cin >> zx >> cx;
getxx(zx, cx);
return 0;
}