a,b=map(int,input().split()) if a%b==0: c=a//b g=1 i=2 while i*i<=c: if c%i==0: f=0 while c%i==0: c//=i f+=1 g*=f+1 i+=1 if c>1: g*=1+1 print(g) else: print(0)