Program tapsirmaC;var a,b,n,x,p:integer; input,output:text;beginp:=0;assign(input,'c.in');assign(output,'c.out');reset(input);rewrite(output);read(input,a,b,n);for x:= 1 to n dobeginif a*x mod n = b then p:=p+1;end; write(output,p);close(input); close(output); end.