#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long a[2000], dp[2000];   long long qmod(long long y) {     long long res = 1, two = (long long)2;     for (; y; y >>= 1) {       if (y & 1) res = res * two % mod;       two = two * two % mod;     }     return res;   }   int main() {     long long x, y;     int cnt = 0;     scanf( %lld%lld , &x, &y);     if (y % x) return 0 * puts( 0 );     for (long long i = 1; i <= sqrt(y); ++i) {       if (y % i == 0) {         if (i % x == 0) a[++cnt] = i;         if (i * i != y && y / i % x == 0) a[++cnt] = y / i;       }     }     sort(a + 1, a + 1 + cnt);     for (int i = cnt; i > 0; --i) {       dp[i] = qmod(y / a[i] - 1);       for (int j = i + 1; j <= cnt; ++j)         if (a[j] % a[i] == 0) dp[i] = ((dp[i] - dp[j]) % mod + mod) % mod;     }     printf( %lld n , dp[1]);     return 0;   }   