#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
getline(cin,s);
string a,b;
cin>>a>>b;
int pos = s.find(a);
if(pos!=string::npos){
for(int i=pos;i<s.size();)
{
int j = 0;
pos = i;
while(a[j]==s[i]){
if(j==a.size()-1){
if((i+1)<s.size()){
if(s[i+1]==' '){
s.erase(pos,a.size());
s.insert(pos,b);
}
}else if(i+1==s.size()){
s.erase(pos,a.size());
s.insert(pos,b);
}
}
j++;
i++;
if(j>=a.size() || i>=s.size())break;
}
while(1)//加速i,一个单词一个单词对比
{
if(i>=s.size())break;
if(s[i]==' '){
i++;
break;
}
i++;
}
}
cout<<s;
}
else{
cout<<s;
}
}