program miller_rabin_primilarity_test;
function bigmultiplication(x,y,n:longint):longint;
var
doi:longint;
begin
doi:=0;
while(y>0) do
begin
if(y mod 2 =1) then
begin
doi:=(doi+x)mod n;
end;
x:=(2*x)mod n;
y:=y div 2;
end;
bigmultiplication:=doi;
end;
function exponents_mod_n(x,y,n:longint):longint;
var
doi,doing:longint;
begin
doing:=x;
doi:=1;
while(y>0) do
begin
if(y mod 2 =1) then
begin
doi:=bigmultiplication(doi,doing,n);
end;
doing:=bigmultiplication(doing,doing,n);
y:=y div 2;
end;
exponents_mod_n:=doi;
end;
function miller_rabin(p1:longint):boolean;
var
a,p,x,prime:Longint;
i,r,s,d:integer;
begin
s:=0;
Randomize;
if p1 mod 2 = 0 then
begin
miller_rabin:=false;
exit;
end;
prime:=p1;
p:=p1-1;
while p mod 2 =0 do
begin
p:= p div 2;
s:=s+1;
end;
d:=p;
for i:=1 to 7 do
begin
a:=random(prime) mod prime + 1 ;
x:=exponents_mod_n(a,d,prime);
r:=0;
while((r<(s-1)) and (x <> 1) and (x<>prime-1) )do
begin
x:=exponents_mod_n(x,2,prime);
if x=1 then
begin
miller_rabin:=false;
exit;
end;
r:=r+1;
end;
end;
miller_rabin:=true;
end;
var
prime:longint;
ans:boolean;
begin
readln(prime);
ans:=miller_rabin(prime);
writeln(ans);
end.
cHJvZ3JhbSBtaWxsZXJfcmFiaW5fcHJpbWlsYXJpdHlfdGVzdDsKZnVuY3Rpb24gYmlnbXVsdGlwbGljYXRpb24oeCx5LG46bG9uZ2ludCk6bG9uZ2ludDsKdmFyIApkb2k6bG9uZ2ludDsKYmVnaW4KCWRvaTo9MDsKCXdoaWxlKHk+MCkgZG8KCWJlZ2luCgkJaWYoeSBtb2QgMiA9MSkgdGhlbgoJCWJlZ2luCgkJCWRvaTo9KGRvaSt4KW1vZCBuOwoJCWVuZDsKCQkKCQl4Oj0oMip4KW1vZCBuOwoJCQl5Oj15IGRpdiAyOwoJZW5kOwoJYmlnbXVsdGlwbGljYXRpb246PWR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