def solver(x, b): div_cnt = 0 for i in range(1, int(x**0.5) + 1): if x%i == 0: if i%b == 0: div_cnt += 1 if (x//i != i) and ((x//i)%b == 0): div_cnt += 1 return div_cnt a, b = map(int, input().split()) print(solver(a, b))