/*
    Keep It Simple!
*/

#include <fstream>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

#ifndef ONLINE_JUDGE
    ifstream cin("data.in");
    ofstream cout("data.out");
#else
    #include<iostream>
#endif // ONLINE_JUDGE

#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//const int kMaxN = 100005;

int aux;
char a,b;
string n;

char tochar(int a)
{
    return '0'+ a;
}

bool Solve()
{
    cin >> n >> aux;
    a = tochar(aux);
    cin >> aux; b = tochar(aux);

    if(n[0] == '0' && a =='0' && b == '0')
        return 0;
    for(int i=0; i<n.size(); ++i)
        if(n[i] == a)
            n[i] = b;

    aux = 0;
    while(n[aux]=='0') ++aux;

    if(aux == n.size())
        cout << '0';
    for(int i=aux; i<n.size(); ++i)
        cout << n[i];
    cout << '\n';
    return 1;
}

int main()
{
    while(Solve());
    return 0;
}