program hh;
uses crt;
var x,y,s,d, count:longint;
function factorial(x:longint):boolean;
var n:byte;
Begin
n:=2;while (x mod n=0) and (x>1) do begin
x:=x div n;
n:=n+1;
end;
factorial:=(x=1)
end;
function nod(x,y:byte):byte;
begin
while x*y<>0 do if x>y then x:=x mod y else y:=y mod x;
nod:=x+y; end;
Begin
writeln('vv chislo'); readln(s);
count:=0;
write('vv element posled'); readln(x);
write('vv element posled'); readln(y);
while not (factorial(y)) do begin
if nod(x,y)=s then count:=count+1;
x:=y;
write('vv element posled'); readln(y);
end;
writeln({'pos coder {count ,par coced chisel,nod
kotor raven '},s)
end.