#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()
{
//memset(kothay,100,-1);
vector <int> kothay;
string s,sub1,sub2;
int pos;
cin>>s>>sub1>>sub2;
string res = Replace(s,sub1,sub2);
cout<<res;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNzdGRpbz4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgTGVuZ3RoKHN0cmluZyBzKQp7CmludCBsZW49MDsKZm9yKGludCBpPTA7c1tpXSE9J1wwJztpKyspCnsKbGVuKys7Cn0KcmV0dXJuIGxlbjsKfQp2ZWN0b3IgPGludD4gU3ViU3RyaW5nRmluZChzdHJpbmcgcywgc3RyaW5nIHN1YikKewogICAgaW50IGxlbnMgPSBMZW5ndGgocyk7CiAgICBpbnQgbGVuc3ViID0gTGVuZ3RoKHN1Yik7CiAgICB2ZWN0b3IgPGludD4gcG9zOwogICAgaW50IHBhaXNpID0gMDsKICAgIGZvcihpbnQgaT0wO2k8PWxlbnMtbGVuc3ViO2krKykKICAgIHsKICAgICAgICBpbnQgbWF0Y2hlZCA9IDA7CiAgICAgICAgZm9yKGludCBqPTA7ajxsZW5zdWI7aisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoc3ViW2pdID09IHNbaStqXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbWF0Y2hlZCsrOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmKG1hdGNoZWQgPT0gbGVuc3ViKQogICAgICAgIHsKICAgICAgICAgICAgcG9zLnB1c2hfYmFjayhpKTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zOwp9CgpzdHJpbmcgRGVsZXRlKHN0cmluZyBzLCBzdHJpbmcgc3ViKQp7CiAgICBpbnQgbGVucyA9IExlbmd0aChzKTsKICAgIGludCBsZW5zdWIgPSBMZW5ndGgoc3ViKTsKICAgIHZlY3RvciA8aW50PiBwb3M7CiAgICBwb3MgPSBTdWJTdHJpbmdGaW5kKHMsc3ViKTsKICAgIHN0cmluZyByZXMgPSAiIjsKICAgIGludCBrb3RvdG9tbyA9IDA7CiAgICBmb3IoaW50IGk9MDtpPGxlbnM7aSsrKQogICAgewogICAgICAgIGlmKGtvdG90b21vID4gcG9zLnNpemUoKSB8fCBpICE9IHBvc1trb3RvdG9tb10pCiAgICAgICAgewogICAgICAgICAgICByZXMgPSByZXMgKyBzW2ldOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICBpKz0gKGxlbnN1Yi0xKTsKICAgICAgICAgICAga290b3RvbW8rKzsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzOwp9CnN0cmluZyBJbnNlcnRBdFBvcyhzdHJpbmcgcywgaW50IHBvcywgc3RyaW5nIHN1YikKewogICAgc3RyaW5nIHJlcyA9ICIiOwogICAgaW50IGxlbnMgPSBMZW5ndGgocyk7CiAgICBpbnQgbGVuc3ViID0gTGVuZ3RoKHN1Yik7CiAgICBmb3IoaW50IGk9MDtpPHBvcztpKyspCiAgICB7CiAgICAgICAgcmVzID0gcmVzICsgc1tpXTsKICAgIH0KICAgIHJlcyA9IHJlcyArIHN1YjsKICAgIGZvcihpbnQgaT1wb3M7aTxsZW5zO2krKykKICAgIHsKICAgICAgICByZXMgPSByZXMgKyBzW2ldOwogICAgfQogICAgcmV0dXJuIHJlczsKfQoKc3RyaW5nIFJlcGxhY2Uoc3RyaW5nIHMsIHN0cmluZyBzdWIxLCBzdHJpbmcgc3ViMikKewogICAgaW50IGxlbnMgPSBMZW5ndGgocyk7CiAgICBpbnQgbGVuc3ViMSA9IExlbmd0aChzdWIxKTsKICAgIGludCBsZW5zdWIyID0gTGVuZ3RoKHN1YjIpOwoKICAgIHZlY3RvciA8aW50PiBwb3M7CiAgICBwb3MgPSBTdWJTdHJpbmdGaW5kKHMsc3ViMSk7CiAgICBzdHJpbmcgcmVzOwogICAgcmVzID0gRGVsZXRlKHMsc3ViMSk7CiAgICBmb3IoaW50IGk9MDtpPHBvcy5zaXplKCk7aSsrKQogICAgewogICAgICAgIHJlcyA9IEluc2VydEF0UG9zKHJlcyxwb3NbaV0rKGkqKGxlbnN1YjItbGVuc3ViMSkpLHN1YjIpOwogICAgfQogICAgcmV0dXJuIHJlczsKfQoKaW50IG1haW4oKQp7CiAgICAvL21lbXNldChrb3RoYXksMTAwLC0xKTsKICAgIHZlY3RvciA8aW50PiBrb3RoYXk7CiAgICBzdHJpbmcgcyxzdWIxLHN1YjI7CiAgICBpbnQgcG9zOwogICAgY2luPj5zPj5zdWIxPj5zdWIyOwogICAgc3RyaW5nIHJlcyA9IFJlcGxhY2UocyxzdWIxLHN1YjIpOwogICAgY291dDw8cmVzOwogICAgcmV0dXJuIDA7Cn0=