import sys def input(): return sys.stdin.readline().rstrip() def prime(): P = [2] L = [1]*(10**6) for i in range(3, 10**6, 2): if L[i]: P.append(i) for j in range(i*i, 10**6, 2*i): L[j] = 0 return P from bisect import bisect def main(): N, K = map(int, input().split()) N -= K P = prime() L = [] for p in P: if N == 1: break while N%p == 0: L.append(p) N //= p T = set() T.add(1) for l in L: S = T.copy() T = S.copy() for s in S: T.add(s*l) S = sorted(list(T)) print(len(S)-bisect(S, K)) if __name__ == "__main__": main()