#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #ifdef DEBUG #define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__); #else #define show(...) 42 #endif using namespace std; using ll = long long; using pii = pair; template ostream& operator<<(ostream& os, pair a) { os << '(' << a.first << ',' << a.second << ')'; return os; } template ostream& operator<<(ostream& os, vector v) { for (auto x : v) os << x << ' '; return os; } void debug() { cerr << '\n'; } template void debug(H a, T... b) { cerr << a; if (sizeof...(b)) cerr << ", "; debug(b...); } template vector divisor(T n) { vector res; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i * i != n) { res.push_back(n / i); } } } sort(res.begin(), res.end()); return res; } template map prime_factor(T n) { map res; for (T i = 2; i * i <= n; i++) { while (n % i == 0) { res[i]++; n /= i; } } if (n != 1) { res[n]++; } return res; } template T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; } template T lcm(T a, T b) { return a / gcd(a, b) * b; } //負の数を掛けたりするとバグる template class Modint{ public: int a; Modint(const long long v = 0):a(v % MOD){} int getmod() const{ return MOD; } Modint operator+(const Modint rhs) const{ return Modint(*this) += rhs; } Modint operator-(const Modint rhs) const{ return Modint(*this) -= rhs; } Modint operator*(const Modint rhs) const{ return Modint(*this) *= rhs; } Modint operator/(const Modint rhs) const{ return Modint(*this) /= rhs; } Modint operator+(const long long rhs) const{ return Modint(*this) += rhs; } Modint operator-(const long long rhs) const{ return Modint(*this) -= rhs; } Modint operator*(const long long rhs) const{ return Modint(*this) *= rhs; } Modint operator/(const long long rhs) const{ return Modint(*this) /= rhs; } friend Modint operator+(const long long a, const Modint b){ return b + a; } friend Modint operator-(const long long a, const Modint b){ return -b + a; } friend Modint operator*(const long long a, const Modint b){ return b * a; } friend Modint operator/(const long long a, const Modint b){ return Modint(a) / b; } Modint &operator+=(const Modint rhs){ a += rhs.a; if(a >= MOD){ a -= MOD; } return *this; } Modint &operator-=(const Modint rhs){ if(a < rhs.a){ a += MOD; } a -= rhs.a; return *this; } Modint &operator*=(const Modint rhs){ a = (long long)a * rhs.a % MOD; return *this; } Modint &operator/=(Modint rhs){ int x = MOD - 2; while(x){ if(x % 2){ *this *= rhs; } rhs *= rhs; x /= 2; } return *this; } Modint &operator++(){ *this += 1; return *this; } Modint &operator--(){ *this -= 1; return *this; } Modint operator++(int){ Modint res = *this; ++(*this); return res; } Modint operator--(int){ Modint res = *this; --(*this); return res; } Modint &operator+=(const long long rhs){ *this += Modint(rhs); return *this; } Modint &operator-=(const long long rhs){ *this -= Modint(rhs); return *this; } Modint &operator*=(const long long rhs){ *this *= Modint(rhs); return *this; } Modint &operator/=(const long long rhs){ *this /= Modint(rhs); return *this; } Modint operator+() const{ return *this; } Modint operator-() const{ return Modint()-*this; } bool operator==(const Modint rhs) const{ return a == rhs.a; } bool operator==(const long long rhs) const{ return a == rhs; } friend bool operator==(const long long a, const Modint b){ return a == b.a; } bool operator!=(const Modint rhs) const{ return a != rhs.a; } bool operator!=(const long long rhs) const{ return a != rhs; } friend ostream &operator<<(ostream &os, const Modint x){ os << x.a; return os; } friend istream &operator>>(istream &is, Modint &x){ is >> x.a; return is; } explicit operator bool() const{ return a > 0; } bool operator!(){ return a == 0; } explicit operator int() const{ return a; } explicit operator long long() const{ return (long long) a; } friend Modint pow(Modint a, long long b){ Modint res = 1; while(b){ if(b % 2){ res *= a; } a *= a; b /= 2; } return res; } }; using mint = Modint<1000000007>; const int NUM = 400005; mint fact[NUM + 1], fact_inv[NUM + 1], inv[NUM + 1]; mint combi(long long N_, long long K_){ static const int Mod_ = fact[0].getmod(); if(fact[0] == 0){ inv[1] = fact[0] = fact_inv[0] = 1; for(int i = 2; i <= NUM; i++){ inv[i] = inv[Mod_ % i] * (Mod_ - Mod_ / i); } for(int i = 1; i <= NUM; i++){ fact[i] = fact[i - 1] * i; fact_inv[i] = fact_inv[i - 1] * inv[i]; } } if(K_ < 0 or K_ > N_) return 0; return fact_inv[K_] * fact[N_] * fact_inv[N_ - K_]; } mint hcomb(long long N_, long long K_){ return ((N_ | K_) == 0) ? 1 : combi(N_ + K_ - 1, K_); } int main(){ int n, k; cin >> n >> k; auto d = divisor(n); mint ans = 0; bool f = true; for(int x : d){ if(x == 1)continue; if(k % x)continue; int l = k / x; auto hoge = prime_factor(x); f = hoge.size() % 2; bool dame = false; for(auto aa:hoge)if(aa.second >1)dame = true; if(dame)continue; f = prime_factor(x).size() % 2; show(x, n/x, l, combi(n/x,l)); if(f)ans += combi(n/x, l); else ans -= combi(n/x, l); } cout << ans << endl; }