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