#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int fstpow(int x, int y) {
  long long now = x;
  long long ans = 1;
  for (long long k = 1; k <= y; k *= 2) {
    if (k & y) {
      ans = (ans * now) % mod;
    }
    now = (now * now) % mod;
  }
  return ans;
}
int mu(int x) {
  int ans = 1;
  for (int a = 2; a <= x; a++) {
    if (x % a == 0) {
      x = x / a;
      if (x % a == 0) return 0;
      ans *= -1;
    }
  }
  return ans;
}
int main() {
  int x, y;
  cin >> x >> y;
  if (y % x != 0) {
    cout << "0";
    return 0;
  }
  int sum = y / x;
  long long ans = 0;
  for (int a = 1; a <= sqrt(sum); a++) {
    if (sum % a == 0) {
      ans = ans + mu(a) * fstpow(2, sum / a - 1);
      if (a * a != sum) ans = ans + mu(sum / a) * fstpow(2, a - 1);
      ans = (ans + mod) % mod;
    }
  }
  cout << ans;
}
