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