def div(n): low, upper = [], [] i = 1 while i * i <= n: if n % i == 0: low.append(i) if i != n // i: upper.append(n//i) i += 1 return low + upper[::-1] a, b = map(int, input().split()) cnt = 0 for i in div(a): if i % b == 0: cnt += 1 print(cnt)