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


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

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

        }

    }

    return 0;
}