def divisor(n):
    ass = []
    for i in range(1, int((n+1)**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i*i < n:
                ass.append(n//i)
    return ass #sortされていない
    
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int((n+1)**0.5)+1):
        if is_prime[i]:
            for j in range(i *2, n + 1, i):
                is_prime[j] = False
    res = [i for i in range(n+1) if is_prime[i]]
    return res

n_ = 10**6
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod

def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod
    
n, k = map(int, input().split())
res = [0]*(n+1)
for x in set(divisor(n)) & set(divisor(k)):
    res[x] = nCr(n//x, k//x)
res[1] = 0
prl = primes(n)
for i in range(n+1):
    if res[i]:
        for p in prl:
            if i*p > n: break
            res[i] = (res[i] - res[i*p]) % mod
print(sum(res) % mod)