#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvi = vector; using vvl = vector; const ll INF = 1LL << 60; const ll MOD = 1000000007; template bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } template void print(const C &c, std::ostream &os = std::cout) { std::copy(std::begin(c), std::end(c), std::ostream_iterator(os, " ")); os << std::endl; } // list up all factors template set factors(T a) { set facs; for (T i = 1; i * i <= a; ++i) { if (a % i == 0) { facs.insert(i); facs.insert(a / i); } } return facs; } template void primeFactors(T a, map &facs) { double sqrtA = sqrt(a); for (int i = 2; i <= sqrtA + 1e-10; ++i) { while (a % i == 0) { facs[i]++; a /= i; } } if (a > sqrtA) facs[a]++; return; } // Eratosthenes's sieve // create list of prime numbers in O(N) // check if the given number is prime in O(1) struct Sieve { vector isPrime; Sieve(size_t max) : isPrime(max + 1, true) { isPrime[0] = false; isPrime[1] = false; for (size_t i = 2; i * i <= max; ++i) // 0からsqrt(max)まで調べる if (isPrime[i]) // iが素数ならば for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は isPrime[i * j] = false; // 素数ではない } bool operator()(size_t n) { return isPrime[n]; } }; struct Combination { vector fac, finv, inv; Combination(ll maxN) { maxN += 100; // for safety fac.resize(maxN + 1); finv.resize(maxN + 1); inv.resize(maxN + 1); fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i <= maxN; ++i) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll operator()(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } }; int main() { int n, k; cin >> n >> k; map primen; map primek; auto nfac = factors(n); auto kfac = factors(k); nfac.erase(1); kfac.erase(1); Sieve isprime(n); Combination nCk(n); ll ret = 0; for (auto &p : kfac) { if (kfac.count(p) > 0) { if (isprime(p)) { ret = (ret + nCk(n / p, k / p)) % MOD; } else { map primes; primeFactors(p, primes); ret -= (nCk(n / p, k / p) * (primes.size()-1)) % MOD; if (ret < 0) ret += MOD; } } } cout << ret << "\n"; return 0; }