#include <bits/stdc++.h>
using namespace std;
inline int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
int main()
{
long long x, y;
cin >> x >> y;
long long tmp = x * y;int ans = (x == y ? -1 : 0);
for (register int i = 1; i * i <= tmp; i++)
{
if (tmp % i == 0)
{
int p = tmp / i;
int q = i;
if (gcd(p, q) == x)
ans +=2;
}
}
cout << ans <<endl;
return 0;
}