rt
#include <cstdio>
#define ll long long
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int main() {
ll x, y;
scanf("%lld %lld", &x, &y);
ll ans = 0;
for (ll i = 2; i * i <= x * y; i++) {
if (gcd(i, x * y / i) == x && x * y % i == 0) ans += 2;
}
printf("%lld", ans);
return 0;
}