var
n,p,l,i:longint;
procedure go(k,m:int64);
var
i:longint;
begin
if m=l+1 then
begin
if k mod p=0 then
begin
writeln(k);
close(input);
close(output);
halt;
end;
exit;
end;
for i:=0 to n-1 do
go(k*10+i,m+1);
end;
function yes:boolean;
var
i:longint;
s:string;
ch:char;
begin
str(p,s);
ch:=chr(n+48);
for i:=1 to length(s) do
if s[i]>ch then exit(false);
exit(true);
end;
begin
assign(input,'sramoc.in'); reset(input);
assign(output,'sramoc.out'); rewrite(output);
readln(n,p);
if yes then
begin
writeln(p);
close(input);
close(output);
halt;
end;
for l:=1 to 100 do
for i:=1 to n-1 do
go(i,2);
close(input);
close(output);
end.