program zht;
var
i,x,z,a,n:longint;
t:int64;
begin
assign(input,'torch.in');
assign(output,'torch.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to 30000 do
begin
t:=i*n;
while t<>0 do
begin
z:=t mod 10;
t:=t div 10;
if (z<>0) and (z<>1) then x:=300;
end;
if x=0 then begin writeln(i);a:=1;break;end else x:=0;
end;
if a=0 then writeln('NO');
close(input);
close(output);
end.