typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

const int MAX = 1000010;
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 main() {
    ll n,k;
    COMinit();
    std::cin >> n>>k;
    vector<ll> prime(n+1,1);
    prime[0] = prime[1] = 0;
    
    for (int i = 1; i < n+1; i++) {
        if(prime[i]==1){
            for(int j = i + i; j < n+1; j+=i){
                prime[j] = i;
            }
        }
    }
    map<ll,ll> memo;
    ll ans = 0;
    for (int i = 2; i < n; i++) {
        if(n%i==0&&k%(n/i)==0){
            memo[i]=COM(i,k/(n/i));
            if(prime[i]==1){
                ans += memo[i];
            }else{
                ans += memo[i];
                ll tmp = i;
                set<ll> s;
                while(prime[tmp]>1){
                    s.insert(prime[tmp]);
                    tmp/=prime[tmp];
                }
                if(tmp!=1){
                    s.insert(tmp);
                }
                for (auto e : s) {
                    ans -= memo[e];
                }
            }
        }
    }
    
    std::cout << ans << std::endl;
}