package mindCoding;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
	public static void main(String[] args){
		try{
			Config c = new Config("data.txt");
			int n = c.getN();
			int c1 = c.getC1();
			int c2 = c.getC2();
			boolean goon  = true;
			
			while(goon){
				int aux= n;
				int newNum = 0;
				int times = 1;
				int finalNum = 0;
				while(aux!=0){
					if(aux % 10 == c1){
						newNum = c2;
					}
					else
						newNum = aux % 10;
					aux = aux / 10;
					finalNum += times * newNum;
					times*=10;
				}
				System.out.println(finalNum);
				 n = c.getN();
				 c1 = c.getC1();
				 c2 = c.getC2();
				 if(n== 0 && c1 ==0 && c2 ==0)
				  goon = false;
			}
			
			
			
			
		}
		catch (FileNotFoundException ex) {
			Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
			
		}
	}
}
	public class Config {
	    
	    private Scanner reader;
	    
	    public Config(String fileName) throws FileNotFoundException {
	        this.reader = new Scanner(new FileReader("E:/Eclipse.WorkSpace/mindCoding/src/mindCoding/"+fileName));
	  
	    }
	    
	    public int getN(){
	    	return reader.nextInt();
	    }
	    public int getC1(){
	    	return reader.nextInt();
	    }
	    public int getC2(){
	    	return reader.nextInt();
	    }
	}