#include<bits/stdc++.h>
using namespace std;
int Length(string s)
{
int len = 0;
for(int i=0;s[i]!='\0';i++)
{
len++;
}
return len;
}
vector <int> SubStringFind(string s, string sub)
{
int lens = Length(s);
int lensub = Length(sub);
vector <int> pos;
int paisi = 0;
for(int i=0;i<=lens-lensub;i++)
{
int matched = 0;
for(int j=0;j<lensub;j++)
{
if(sub[j] == s[i+j])
{
matched++;
continue;
}
else
break;
}
if(matched == lensub)
{
pos.push_back(i);
}
}
return pos;
}
string Delete(string s, string sub)
{
int lens = Length(s);
int lensub = Length(sub);
vector <int> pos;
pos = SubStringFind(s,sub);
string res = "";
int kototomo = 0;
for(int i=0;i<lens;i++)
{
if(kototomo > pos.size() || i != pos[kototomo])
{
res = res + s[i];
}
else
{
i+= (lensub-1);
kototomo++;
}
}
return res;
}
string InsertAtPos(string s, int pos, string sub) {
string res = "";
int lens = Length(s);
int lensub = Length(sub);
for(int i=0;i<pos;i++)
{
res = res + s[i];
}
res = res + sub;
for(int i=pos;i<lens;i++)
{
res = res + s[i];
}
return res;
}
string Replace(string s, string sub1, string sub2) {
int lens = Length(s);
int lensub1 = Length(sub1);
int lensub2 = Length(sub2);
vector <int> pos;
pos = SubStringFind(s,sub1);
string res;
res = Delete(s,sub1);
for(int i=0;i<pos.size();i++)
{
res = InsertAtPos(res,pos[i]+(i*(lensub2-lensub1)),sub2);
}
return res;
}
int main()
{
vector <int> kothay;
string s,sub1,sub2;
int pos;
cin>>s>>sub1>>sub2;
string res = Replace(s,sub1,sub2);
cout<<res;
return 0;
}
CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBMZW5ndGgoc3RyaW5nIHMpCiB7IAppbnQgbGVuID0gMDsgCmZvcihpbnQgaT0wO3NbaV0hPSdcMCc7aSsrKSAKeyAKbGVuKys7IAp9IApyZXR1cm4gbGVuOwogfSAKCnZlY3RvciA8aW50PiBTdWJTdHJpbmdGaW5kKHN0cmluZyBzLCBz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