#include<iostream>
#include<map>
#include<vector>
#include<deque>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<string>
using namespace std;
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define mm(a, b) memset(a, b, sizeof(a))
#define ll long long
#define mp make_pair
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
ll n;
ll gcd(ll a, ll b){
return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
}
void solve() {
ll x, y;
cin >> x >> y;
if (x == y) {
cout << 1;
return;
}
ll ans = 0;
for (ll i = x; i <= y; i += x)
for (ll j = i; j <= y; j += x)
if (lcm(i, j) == y && gcd(i, j) == x) ans += 2;
cout << ans;
}
int main() {
ios;
int t;
t = 1;
while (t--) solve();
return 0;
}