#include<bits/stdc++.h>
using namespace std;
string s1,s2,s3;
int now,nextt[1000005],j;
inline int kmp()
{ j=0;
for(register int i=0;i<s1.size();++i)
{ while(j&&s1[i]!=s2[j])j=nextt[j];
if(s1[i]==s2[j])++j;
if(j==s2.size())return i-s2.size()+2;
}
return 10000005;
}
int main()
{ getline(cin,s1);
getline(cin,s2);
nextt[0]=0;
j=0;
for(register int i=1;i<s2.size();++i)
{ while(j&&s2[i]!=s2[j])j=nextt[j];
if(s2[i]==s2[j])nextt[i+1]=++j;
else nextt[i+1]=0;
}
now=kmp()-1;
while(now<=s1.size()&&now>=0)
{ s1.replace(now,s2.size(),s3);
now=kmp()-1;
}
cout<<s1;
return 0;
}