#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; vector inv,fact,invfact; void mod_build(int n=101010){ fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1); fact[0]=inv[0]=invfact[0]=1; inv[1]=1; rep(i,n){ fact[i+1]=fact[i]*(i+1)%mod; if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod; invfact[i+1]=invfact[i]*inv[i+1]%mod; } } ll perm(int n,int k){ if(n<0||k<0||k>n)return 0; return fact[n]*invfact[n-k]%mod; } ll comb(int n,int k){ if(n<0||k<0||k>n)return 0; return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; } ll powmod(ll n,ll k){ k%=mod-1; if(k<0)k+=mod-1; ll ret=1; while(k){ if(k&1)ret=ret*n%mod; n=n*n%mod; k>>=1; } return ret; } int main(){ int n,k; cin>>n>>k; mod_build(n+5); vector res(n+1); REP(i,2,n){ if(k%i==0&&n%i==0){ res[n/i]=comb(n/i,k/i); } } vector used(n+1,false); used[0]=used[1]=1; rep(i,n+1){ if(used[i])continue; for(int j = 2*i;j<=n;j+=i){ used[j]=1; res[j]+=mod-res[i]; res[j]%=mod; } } ll ans = 0; REP(i,2,n){ if(k%i==0&&n%i==0){ ans+=res[n/i]; } } cout<