#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return int(a * 1ll * b % mod); }
int pow2(int x) {
  if (!x) return 1;
  if (x & 1) {
    return mul(2, pow2(x - 1));
  }
  int z = pow2(x / 2);
  return mul(z, z);
}
map<int, int> was[2];
int solve(int y, int m) {
  if (was[m].count(y)) {
    return was[m][y];
  }
  if (!m) {
    return sub(pow2(y - 1), solve(y, 1));
  }
  int res = 0;
  for (int i = 1; i * i <= y; i++) {
    if (y % i == 0) {
      int a = y / i;
      res = add(res, solve(i, 0));
      if (a != i && a != y) {
        res = add(res, solve(a, 0));
      }
    }
  }
  return was[m][y] = res;
}
int main() {
  int x, y;
  cin >> x >> y;
  if (y % x) {
    cout << 0;
    return 0;
  }
  y /= x;
  was[0][1] = 1;
  was[1][1] = 1;
  cout << solve(y, 0);
  return 0;
}
