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