program sramoc;
var
i,j,k,m,n:longint;
l:int64;
function pan(const x:int64):boolean;
var
i:longint;
j:int64;
begin
j:=x;
while j<>0 do
begin
i:=j mod 10;
if i>=k then
exit(false);
j:=j div 10;
end;
exit(true);
end;
begin
assign(input,'sramoc.in');
reset(input);
assign(output,'sramoc.out');
rewrite(output);
readln(k,m);
i:=1;
while 1=1 do
begin
l:=m*i;
if pan(l) then
begin
writeln(l);
break;
end;
inc(i);
end;
close(input);
close(output);
end.