def divisor(n): ass = list() r = int((n+1)**0.5) for i in range(1, r+1): if n%i == 0: ass.append(i) if i*i < n: ass.append(n//i) return ass #sortされていない def fctr1(n): f = list() r = int((n+1)**0.5) for i in range(2, r+1): if n % i == 0: c = 0 while n % i == 0: c += 1 n //= i f.append(i) if n > 1: f.append(n) return f 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) prl = sorted(set(fctr1(n)) & set(fctr1(k))) div = sorted(set(divisor(n)) & set(divisor(k)))[1:] for x in div: res[x] = nCr(n//x, k//x) for p in prl: for i in div: if i*p > n: break res[i] = (res[i] - res[i*p]) % mod print(sum(res) % mod)