def div(n): i = 1 SS = set() while i * i <= n: if n % i == 0: SS.add(i) SS.add(n//i) i += 1 return sorted(list(SS)) A, B = map(int, input().split()) ans = 0 for d in div(A): if d % B == 0: ans += 1 print(ans)