a,b=map(int,input().split()) hs={} d=1 while d*d<=a: if a%d==0: if d%b==0:hs[d]=0 c=a//d if c%b==0:hs[c]=0 d+=1 print(len(hs))