//#include <fstream>
#include <iostream>
using namespace std;
/*ifstream f("nc1c2.in");
ofstream g("nc1c2.out");*/
int main()
{
    //char c1, c2;
    string n, c1, c2;
    bool k=false;
    while (k==false){
        //f>>n>>c1>>c2;
        cin>>n>>c1>>c2;
        if(n=="0" && c1=="0" && c2=="0") k=true;
            else{
                while(n.find(c1)<n.length()){
                n.replace(n.find(c1),1,c2);
                }
                while(n[0]=='0') n.erase(0,1);
                //g<<n<<endl;
                cout<<n<<endl;
            }
    }
    /*f.close();
    g.close();*/
    return 0;
}