#include <bits/stdc++.h>
using namespace std;
long long x, y;
const int mod = 1e9 + 7;
map<int, int> mp;
long long ksm(long long a, long long b, long long mod) {
  long long res = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) res = res * a % mod;
  return res;
}
long long dfs(int x) {
  if (mp.count(x)) return mp[x];
  if (x == 1) return mp[x] = 1;
  long long res = ksm(2, x - 1, mod);
  for (int i = 1; i * i <= x; ++i)
    if (x % i == 0) {
      if (i == 1 || i * i == x)
        (res -= dfs(i)) %= mod;
      else
        (res -= dfs(i) + dfs(x / i)) %= mod;
    }
  return mp[x] = (res % mod + mod) % mod;
}
int main() {
  cin >> x >> y;
  if (y % x) return puts("0") == 2333;
  cout << dfs(y / x);
  return 0;
}
