#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

int main()
{
   ll a,b,c;
   cin>>a>>b;
   c=gcd(a,b);
   a=c;
   
   ll ans=0;
   for(int i=2;i*i<=a;i++)
   {
       if(c%i==0)
       {ans++;
        c/=i;
        while(c%i==0)
            c/=i;
       }
       if(c==1) break;

   }
   if(c!=1) ans+=1;
    ans+=1;
    cout<<ans<<endl;
    return 0;

}
