import sys def input(): return sys.stdin.readline().rstrip() from bisect import bisect 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 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 S = set() S.add(1) for l in L: T = S.copy() for s in S: T.add(s*l) S = T.copy() S = sorted(list(S)) print(len(S)-bisect(S, K)) if __name__ == "__main__": main()