#include <iostream>
#include <fstream>
using namespace std;


int main()
{
    //freopen("input.in","r", stdin);

    while ( !feof(stdin) )
    {
        int n ;
        short c1 , c2 ;
        cin >> n >> c1 >> c2;
        if( n == 0  && c1 == 0 && c2 == 0 ) putchar('\n') ;
        else
        {
            int dummy = 0 ;
            for (int i = 1000000 ; i >0 ; i = i /10 )
            {
                if ( ((n / i )%10) == c1  )
                    dummy = dummy * 10 + c2 ;
                else dummy = dummy * 10 + ((n / i )%10) ;
            }
            cout << dummy << '\n' ;

        }

    }

    return 0;
}