#include <bits/stdc++.h>
using namespace std;
bitset<1000001> bs;
vector<long long> primes;
long long gcd(long long a, long long b) {
if (a < b) return gcd(b, a);
if (b == 0) return a;
return gcd(b, a % b);
}
void sieve()
{
bs.set();
bs[0] = bs[1] = 0;
for(int p=2; p*p<=1000000; p++)
{
if(bs[p])
{
for(int i=p*p; i<=1000000; i+=p)
bs[i] = 0;
}
}
}
int main()
{
cin.tie(0);
cin.sync_with_stdio(0);
long long a,b,ans=1;
cin >> a >> b;
a = gcd(a,b);
sieve();
for(long long j=2;j<=1000000;j++){
if(bs[j]) primes.push_back(j);
}
for(long long i:primes)
{
if (a%i == 0) ans++;
while(a%i==0)
a /= i;
}
if(a!=1) ans++;
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpiaXRzZXQ8MTAwMDAwMT4gYnM7CnZlY3Rvcjxsb25nIGxvbmc+IHByaW1lczsKbG9uZyBsb25nIGdjZChsb25nIGxvbmcgYSwgbG9uZyBsb25nIGIpIHsKCWlmIChhIDwgYikgcmV0dXJuIGdjZChiLCBhKTsKCWlmIChiID09IDApIHJldHVybiBhOwoJcmV0dXJuIGdjZChiLCBhICUgYik7Cn0Kdm9pZCBzaWV2ZSgpCnsKICAgIGJzLnNldCgpOwogICAgYnNbMF0gPSBic1sxXSA9IDA7CiAgICBmb3IoaW50IHA9MjsgcCpwPD0xMDAwMDAwOyBwKyspCiAgICB7CiAgICAgICAgaWYoYnNbcF0pCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IGk9cCpwOyBpPD0xMDAwMDAwOyBpKz1wKQogICAgICAgICAgICAgICBic1tpXSA9IDA7CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGNpbi50aWUoMCk7CiAgICBjaW4uc3luY193aXRoX3N0ZGlvKDApOwoKICAgIGxvbmcgbG9uZyBhLGIsYW5zPTE7CiAgICBjaW4gPj4gYSA+PiBiOwogICAgYSA9IGdjZChhLGIpOwogICAgc2lldmUoKTsKICBmb3IobG9uZyBsb25nIGo9MjtqPD0xMDAwMDAwO2orKyl7CiAgICBpZihic1tqXSkgcHJpbWVzLnB1c2hfYmFjayhqKTsKICB9CiAgICAgIGZvcihsb25nIGxvbmcgaTpwcmltZXMpCiAgICB7CiAgICAgICAgaWYgKGElaSA9PSAwKSBhbnMrKzsKICAgICAgICB3aGlsZShhJWk9PTApCiAgICAgICAgICAgIGEgLz0gaTsKICAgIH0KICAgIGlmKGEhPTEpIGFucysrOwoKCWNvdXQgPDwgYW5zOwogICAgcmV0dXJuIDA7Cn0KCgoK