#include<iostream>
#include<cstdio>
#include<vector>
#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;
}
I2luY2x1ZGU8aW9zdHJlYW0+IAojaW5jbHVkZTxjc3RkaW8+IAojaW5jbHVkZTx2ZWN0b3I+IAojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgTGVuZ3RoKHN0cmluZyBzKQogeyAKaW50IGxlbiA9IDA7IApmb3IoaW50IGk9MDtzW2ldIT0nXDA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