program cojs1417;
var
i,m,q,p:longint;
function gcd(a,b:longint):longint;
var
r:longint;
begin
while b<>0 do
begin
r:=b; b:=a mod b; a:=r;
end;
exit(a);
end;
begin
assign(input,'gcdpro.in');
assign(output,'gcdpro.out');
reset(input);
rewrite(output);
m:=0;
readln(p,q);
if q mod p<>0 then
begin
writeln(0);
halt;
end;
q:=q div p;
for i:=1 to q do
if q mod i=0 then
if gcd(i,q div i)=1 then
inc(m);
writeln(m);
close(input);
close(output);
end.