#include<iostream> #include<cmath> #define maxn 100010 #define ll long long usingnamespacestd;
constint p = 1000000007;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1, x = x * x % p) if (n & 1) s = s * x % p; return s; }
int pri[maxn], cnt; bool isp[maxn]; voidinit_isp(int n){ for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; } } }
intmu(int x){ ll ans = 1; for (int i = 1; i <= cnt && pri[i] <= x / pri[i]; ++i) if (x % pri[i] == 0) { int s = 0; while (x % pri[i] == 0) ++s, x /= pri[i]; if (s > 1) return0; ans *= -1; } if (x > 1) ans *= -1; return ans; }
int x, y, n;
ll solve(int d){ return mu(d) * pow_mod(2, n / d - 1) % p; }
cin >> x >> y; n = y / x; init_isp(sqrt(n)); if (y % x) returncout << 0 << "\n", 0; ll ans = 0; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) ans = (ans + solve(i)) % p; if (n % i == 0 && i * i != n) ans = (ans + solve(n / i)) % p; } cout << (ans + p) % p << "\n"; return0; }