#include <iostream>
#include <algorithm>
#include <vector>

#define MOD 1000000007
#define N_MAX 1000001

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
ll pow2[N_MAX];
bool isPrime[N_MAX];

int W, B, N;

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    pow2[0] = 1;
    pow2[1] = 2;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
        pow2[i] = (pow2[i-1]*2)%MOD;
    }
    for(int i=2;i<N_MAX;i++){
        isPrime[i] = true;
    }
    for(int i=2;i*i<N_MAX;i++){
        for(int j = 2; j*i < N_MAX; j++){
            isPrime[i*j] = false;
        }
    }
}

ll inv_(ll n){
    if(n == 1) return 1;
    else return MOD-inv_(MOD%n)*(MOD/n)%MOD;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

int main(){
    init();
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<int> v;
    for(ll i = 2; i <= N; i++){
        if(N%i == 0 && K%i == 0) {
            v.push_back(N/i);
        }
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++){
        int cnt = 0;
        for(int j = i+1; j < v.size(); j++){
            if(v[j]%v[i] == 0) cnt++;
        }
       // cout << v[i] << ' ';
        int k = N/v[i];
        if(cnt%2 == 0)ans += comb(N/k, K/k);
        else ans -= comb(N/k, K/k);
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;   
}