program t5p4n1;
var a,b,c,d,m,n: longint;
begin
writeln ('vvedit chislo');
readln (n);
writeln ('vvedit zifry yaky treba zaminutu');
readln (a);
writeln ('vvedit zifry na yaky treba zaminutu');
readln (b);
m:=0;
d:=1;
repeat
c:=n mod 10;
if c=a then c:=b;
m:=m+c*d;
d:=d*10;
n:=n div 10;
until n=0;
writeln (m);
readln
end.