#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])
{
primes.push_back(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 i:primes)
{
if (a%i == 0) ans++;
while(a%i==0)
a /= i;
}
if(a!=1) ans++;
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpiaXRzZXQ8MTAwMDAwMT4gYnM7CnZlY3Rvcjxsb25nIGxvbmc+IHByaW1lczsKbG9uZyBsb25nIGdjZChsb25nIGxvbmcgYSwgbG9uZyBsb25nIGIpIHsKCWlmIChhIDwgYikgcmV0dXJuIGdjZChiLCBhKTsKCWlmIChiID09IDApIHJldHVybiBhOwoJcmV0dXJuIGdjZChiLCBhICUgYik7Cn0Kdm9pZCBzaWV2ZSgpCnsKICAgIGJzLnNldCgpOwogICAgYnNbMF0gPSBic1sxXSA9IDA7CiAgICBmb3IoaW50IHA9MjsgcCpwPD0xMDAwMDAwOyBwKyspCiAgICB7CiAgICAgICAgaWYoYnNbcF0pCiAgICAgICAgewogICAgICAgIHByaW1lcy5wdXNoX2JhY2socCk7CiAgICAgICAgICAgIGZvcihpbnQgaT1wKnA7IGk8PTEwMDAwMDA7IGkrPXApCiAgICAgICAgICAgICAgIGJzW2ldID0gMDsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCkKewogICAgY2luLnRpZSgwKTsKICAgIGNpbi5zeW5jX3dpdGhfc3RkaW8oMCk7CgogICAgbG9uZyBsb25nIGEsYixhbnM9MTsKICAgIGNpbiA+PiBhID4+IGI7CiAgICBhID0gZ2NkKGEsYik7CiAgICBzaWV2ZSgpOwogICAgICBmb3IobG9uZyBsb25nIGk6cHJpbWVzKQogICAgewogICAgICAgIGlmIChhJWkgPT0gMCkgYW5zKys7CiAgICAgICAgd2hpbGUoYSVpPT0wKQogICAgICAgICAgICBhIC89IGk7CiAgICB9CiAgICBpZihhIT0xKSBhbnMrKzsKCgljb3V0IDw8IGFuczsKICAgIHJldHVybiAwOwp9CgoKCg==