a, b = map(int, input().split()) nums = [i for i in range(1, a+1) if a % i == 0] ans = [i for i in nums if i % b == 0] print(len(ans))