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