#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
using namespace std;

int n,c1,c2,a[20];

int main()
{
    int i,j,aux;
    bool ok=0;
    //freopen("date.in","r",stdin);
    //freopen("date.out","w",stdout);
    cin.sync_with_stdio(false);
    for (j=1;ok==0;j++)
        {
            cin>>n>>c1>>c2;a[0]=0;
            if (n==0 && c1==0 && c2==0) ok=1;
            else{
            while (n)
                {
                    a[++a[0]]=n%10;
                    n/=10;
                }
            for (i=1;i<=a[0];i++)
                if (a[i]==c1)
                    a[i]=c2;
            for (i=a[0];i>=1 && a[i]==0;i--) ;
            if (i==0) cout<<"0";
            else for (;i>=1;i--) cout<<a[i];
            cout<<"\n";}
        }
    return 0;
}