#include using namespace std; typedef long long ll; #define F first #define S second #define pii pair #define eb emplace_back #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep3(i, l, n) for (int i = l; i < (n); ++i) #define sz(v) (int)v.size() #define inf (int)(1e9+7) #define abs(x) (x >= 0 ? x : -(x)) #define ceil(a, b) a / b + !!(a % b) template inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } template T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; } template T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int n, k; ll dp[1010101]; void solve() { cin >> n >> k; rep3(x, 1, n) if (n % x == 0) { int p = n / x; if (k % p != 0) continue; dp[x] = COM(x, k / p); } // rep3(x, 1, n) cout << dp[x] << " "; cout << endl; ll ret = 0; rep3(x, 1, n) if (dp[x]) { ret += dp[x]; // g(x)の総和が解 // zにとっては約数分を引く // ただし, zはnの約数 // f(z)からg(x)を順次引く -> g(x)を確定 for (int z = x * 2; z <= n; z += x) if (n % z == 0) (dp[z] += MOD - dp[x]) %= MOD; } // rep3(x, 1, n) cout << dp[x] << " "; cout << endl; cout << ret % MOD << endl; } int main() { COMinit(); solve(); }