N = 10**6+50 mod = 10**9+7 fac = [1]*(N+1) finv = [1]*(N+1) for i in range(N): fac[i+1] = fac[i] * (i+1) % mod finv[-1] = pow(fac[-1], mod-2, mod) for i in reversed(range(N)): finv[i] = finv[i+1] * (i+1) % mod def cmb1(n, r, mod): if r <0 or r > n: return 0 r = min(r, n-r) return fac[n] * finv[r] * finv[n-r] % mod n, k = map(int, input().split()) X = [0]*(n+1) ans = 0 for i in range(2, n): if n%i == 0: p = n//i if k%p == 0: x = cmb1(i, k//p, mod) X[i] += x ans += X[i] j = 2*i while j <= n: if n%j == 0: X[j] -= X[i] j += i print(ans%mod)