#include<bits/stdc++.h>
using namespace std;
string x,h,z;
int y;
void w(string s,int o)
{
if(s.size()<=1)
{
cout<<s;
y++;
return;
}
int n=0;
if(o>x.size())
{
y--;o--;
}
n=s.find(x[o]);
string qq,hh;
qq=s.substr(0,n);
hh=s.substr(n+1);
y++;
w(qq,y);
w(hh,y);
cout<<s[n];
return;
}
int main()
{
cin>>z>>x;
w(z,y);
return 0;
}