#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c0){ if(b%2) ret = (ret*num)%P; num = (num*num)%P; b /= 2; } return ret; } struct ml{ ll n; ml(ll n):n(n){if(n>=P) n%=P;} ml operator + (ml a){return (this->n + a.n)%P;} ml operator - (ml a){return (this->n - a.n + P)%P;} ml operator * (ml a){return (this->n * a.n)%P;} ml operator / (ml a){return (this->n*(a.n<=N_MAX?inv[a.n]:mpow(a.n,P-2)))%P;} ml operator + (ll a){return (this->n + a)%P;} ml operator - (ll a){return (this->n - a + P)%P;} ml operator * (ll a){return (this->n * a)%P;} ml operator / (ll a){return (this->n*(a<=N_MAX?inv[a]:mpow(a,P-2)))%P;} ml operator ^ (ll a){return mpow(this->n, a);} void operator += (ml a){n = (this->n + a.n)%P;} void operator -= (ml a){n = (this->n - a.n + P)%P;} void operator *= (ml a){n = (this->n * a.n)%P;} void operator /= (ml a){n = (this->n*(a.n<=N_MAX?inv[a.n]:mpow(a.n,P-2)))%P;} void operator += (ll a){n = (this->n + a)%P;} void operator -= (ll a){n = (this->n - a + P)%P;} void operator *= (ll a){n = (this->n * a)%P;} void operator /= (ll a){n = (this->n*(a<=N_MAX?inv[a]:mpow(a,P-2)))%P;} void operator ^= (ll a){n = mpow(this->n, a);} }; int main(int argc, char const *argv[]) { init(); ll n,k;std::cin >> n>>k; vll d; for(ll i=2;i*i<=n;i++){ if(n%i==0){ d.push_back(i); if(i*i!=n) d.push_back(n/i); } } if(n!=1) d.push_back(n); ll x = k, y = n - k; vll ans(1000001, 0); for(auto e:d){ if(x%e==0&&y%e==0){ ans[e] = comb((x+y)/e, x/e); } } sort(all(d)); for(int i=d.size()-1;i>=0;i--){ for(int j=i-1;j>=0;j--){ if(x%d[i]||x%d[j]||y%d[i]||y%d[j]) continue; if(d[i]%d[j]==0) ans[d[j]] = (ans[d[j]] - ans[d[i]] + P)%P; } } ll s = 0; for(auto e:d) s = (s + ans[e])%P; std::cout << s << '\n'; return 0; }