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

char n[100005], c1, c2;

int main()
{
    while( 1 )
    {
        cin >> n >> c1 >> c2;
        if ( strcmp(n, "0") == 0 && c1 == '0' && c2 == '0' )
            break;
        unsigned int i = 0;
        while ( n[i] == c1 && c2 == '0' && i < strlen(n) )
            i++;
        if ( i == strlen(n) )
            cout << "0\n";
        else
        {
            for ( ; i < strlen(n); i++ )
                if ( n[i] == c1 )
                    cout << c2;
                else
                    cout << n[i];
            cout << '\n';
        }

    }
    return 0;
}