#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
//#define maxi 1e18
#define pll pair<ll,ll>
#define inf 1000000007
#define mod 998244353
map<ll,ll> m;
int main(){
    ll A,B;
    cin>>A>>B;
    ll i;
    vector<ll> v;
    set<ll> s1,s;
    for(i=2;i*i<=A;i++){
        if(A%i==0){
            s1.insert(i);
            while(A%i==0){
                A/=i;
            }
        }
    }
   // sort(all(v));
    if(A>2&&s1.count(A)==0)s1.insert(A);
    for(i=2;i*i<=B;i++){
        if(B%i==0){
            s.insert(i);
            while(B%i==0){
                B/=i;
            }
        }
    }
     if(B>2&&s.count(B)!=1)s.insert(B);
    ll cnt=0;
    for(ll x:s){
        //cout<<x<<endl;
    }
  //  cout<<"HJJ"<<endl;
    for(ll x:s1){
            //cout<<x<<endl;
        if(s.count(x)!=0)cnt++;
    }
   cout<<cnt+1;

    /*for(i=0;i<n+3;i++){
        cout<<v[i]<<endl;
    }
    ll n,i;
    cin>>n;
    ll a[n];
    vector<vector<ll> > v(2);
    for(i=0;i<n;i++){
        cin>>a[i];
        ll r=sqrt(a[i]);
        if(a[i]!=r*r){
            if(a[i]-r*r<(r+1)*(r+1)-a[i]){
                v[0].pb(a[i]-r*r);
            }
            else v[0].pb((r+1)*(r+1)-a[i]);
        }
        else if(a[i]==0){
            v[2].pb(0);
        }
        else {
            v[1].pb(0);
        }
    }
    ll sum=0,cnt=0;
    sort(all(v[0]));
    sort(all(v[1]));
    for(i=0;i<v[0].size();i++){
        sum+=v[0][i];
    }
   // cout<<v[0].size()<<endl;
    for(i=1ll*v[0].size()-1;i>=0;i--){
           // cout<<"HI"<<endl;
        if(cnt<n/2){sum-=v[0][i];cnt++;}
        else break;
    }
    ll diff=(n/2)-cnt;
    while(diff>0){
        for(i=v[1].size()-1;i>=0;i--){
            if(diff>0){
                diff--;
                sum++;
            }
            else break;
        }
    }
    cout<<sum<<endl;
   /*
    ll n,don=0;
    cin>>n;
    ll i,z=0;
    ll a[n];
    ll sum=0;
    vector<ll> ans;
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(a[i]==0){
            z=1;
        }
    }
    sort(a,a+n);
    if(!z){
        cout<<-1;
        return 0;
    }
   ll  nz=0;
    if(sum%3==0){
        for(i=0;i<n;i++){
            ans.pb(a[i]);
            if(a[i]!=0)nz=1;
        }
        if(!nz){
            ans.clear();ans.pb(0);
        }
    }
    else if(sum%3==1){
        for(i=0;i<n;i++){
            if(!don&&a[i]%3==1){
                don=1;
            }
            else ans.pb(a[i]);
        }
         if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==2){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    else{
        for(i=0;i<n;i++){
            if(a[i]%3==2)don=1;
            else ans.pb(a[i]);
        }
        if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==1){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    reverse(all(ans));
    for(i=0;i<ans.size();i++){
        cout<<ans[i];
    }*/
}


Measured memory_bytes: 256