#include <iostream>
#include <cstring>

using namespace std;

int main(){
	char n[64], *p;
	char c1, c2;
	while (true){
		cin >> n >> c1 >> c2;
		if (strcmp(n, "0") || c1-'0' || c2-'0'){
			p = n;
			while (p && *p){
				p = strchr(p, c1);
				if (p){
					n[p - n] = c2;
					p++;
				}
			}
			cout << atoi(n) << endl;
		}
		else break;
	}
	return 0;
}