#include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int P = 1000000007; ll powmod(ll n, ll k) { ll r = 1, t = n % P; for (; k != 0; k /= 2) { if (k & 1) r = r * t % P; t = t * t % P; } return r; } ll inv(ll n) { return powmod(n, P - 2); } vector f0, f1; void init(int n) { f0.resize(n + 1); f0[0] = 1; for (int i = 1; i <= n; i++) { f0[i] = (ll)f0[i - 1] * i % P; } f1.resize(n + 1); f1[n] = inv(f0[n]); for (int i = n; i > 0; i--) { f1[i - 1] = (ll)f1[i] * i % P; } } ll fact(int k) { return f0[k]; } ll comb(int n, int k) { if (n < k || k < 0) return 0; return (ll)f0[n] * f1[k] % P * f1[n - k] % P; } int main() { int n, k; cin >> n >> k; if (n == k) { cout << 1 << endl; exit(0); } init(n); ll r = 0; //長さlのm個に分ける それぞれにc個入る //長さがlの約数のやつはカウント済み vector b(n / 2 + 1, 0); for (int l = n / 2; l >= 2; l--) { if (n % l == 0) { int m = n / l; if (k % m == 0) { int x = 1; for (int i = l * 2; i <= n / 2; i += l) { x -= b[i]; } int c = k / m; r += comb(l, c) * x; r %= P; b[l] = 1; } } } if (r < 0) r += P; cout << r << endl; return 0; }