#include using namespace std::literals::string_literals; using i64 = long long; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n, k; scanf("%d%d", &n, &k); if((n ^ k) & 1) { printf("0\n"); return 0; } const int MOD = 1e9 + 7; auto pow = [&](i64 x, i64 n) { i64 ret = 1; while(n) { if(n & 1) (ret *= x) %= MOD; (x *= x) %= MOD; n >>= 1; } return ret; }; auto inv = [&](i64 n) { return pow(n, MOD - 2); }; std::vector fact(n + 1, 1); for(i64 i = 0; i < n; i++) fact[i + 1] = fact[i] * (i + 1); auto comb = [&](int n, int r) { if(n < r) return 0LL; return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD; }; i64 ans = 0; std::vector latte(n, 0); for(int i = 1; i < n; i++) { if(n % i) continue; int cnt = n / i; if(k % cnt) continue; int loop = k / cnt; (ans += comb(i, loop)) %= MOD; (latte[i] = comb(i, loop)) %= MOD; for(int j = 2; j * j <= i; j++) { if(i % j) continue; ans = (ans - latte[j] + MOD) % MOD; if(j != i / j) ans = (ans - latte[i / j] + MOD) % MOD; } } printf("%lld\n", ans); return 0; }