def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divisors[::-1] def main(): a, b = map(int, input().split()) ans = len([x for x in make_divisors(a) if x % b == 0]) print(ans) if __name__ == "__main__": main()