program sramoc(input,output);
var m,n,b,c,i:longint;
k,a:qword;
f,g:boolean;
l:set of 0..10;
begin
assign(input,'sramoc.in');
reset(input);
assign(output,'sramoc.out');
rewrite(output);
readln(m,n);
for i:=0 to m-1 do
l:=l+[i];
g:=false;
i:=1;
while not g do
begin
inc(k,n);
a:=k;
g:=true;
while (a<>0)and g do
begin
if not(a mod 10 in l) then g:=false;
a:=a div 10;
end
end;
writeln(k);
close(input);
close(output);
end.