#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool isprime(ll x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0)return false;
    }
    return true;
}

int main()
{
    vector<ll>common;
    ll a,b;
    cin>>a>>b;
    set<ll>f,g;
    bool ok=false;
    while (a % 2 == 0)
    {
        f.insert(2);
        a = a/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(a); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (a % i == 0)
        {
            f.insert(i);
            a = a/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (a > 2)
        f.insert(a);

         while (b % 2 == 0)
    {
        g.insert(2);
        b = b/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(b); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (b % i == 0)
        {
            g.insert(i);
            b = b/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (b > 2)
        g.insert(b);


      ll ans=0;
      for(auto x:g){
        if(f.count(x))ans++;
      }
      ans++;
      cout<<ans;

    return 0;

}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}

// 素因数分解 O(√n)
// たとえば 60 = 2^2 x 3 x 5 だったら {(2, 2), (3, 1), (5, 1)} を返す
// 素因数の個数はlogn
vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0) continue;
        int num=0; // 指数
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back({p,num});
    }
    if(n!=1) res.push_back({n,1});
    return res;
}


int main(){
    ll a,b;
    cin>>a>>b;

    ll g=gcd(a,b);

    if(g==1){
        cout<<1<<endl;
        return 0;
    }

    auto pf=prime_factorize(g);
    cout<<pf.size()+1<<endl;
}
