#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
int main()
{
	ll a,b;
	while(~sf("%lld %lld",&a,&b))
	{
		ll g=__gcd(a,b);

		int cnt=0;
		if(g%2==0)
		{
			cnt++;
			while(g%2==0)g/=2;
		}

		for(int i=3;i<=sqrt(g);i++)
		{
			if(g%i==0)
			{
				cnt++;
				while(g%i==0)g/=i;
			}
		}
		if(g>1)cnt++;
		pf("%d\n",cnt+1);
	}
    return 0;
}


































#include <bits/stdc++.h>
using namespace std;

long long mod = 1000000007;

class UnionFind
{
public:
   vector<int> parent;
   UnionFind(int N)
   {
      for (int i = 0; i < N; i++)
      {
         parent.push_back(-1);
      }
   }
   int root(int A)
   {
      if (parent[A] < 0)
         return A;
      return parent[A] = root(parent[A]);
   }
   int size(int A)
   {
      return -parent[root(A)];
   }

   bool unite(int A, int B)
   {
      A = root(A);
      B = root(B);
      if (A == B)
         return false;
      if (size(A) < size(B))
         swap(A, B);
      parent[A] += parent[B];
      parent[B] = A;
      return true;
   }
};
vector<pair<long long, long long>> prime(long long N)
{
   vector<pair<long long, long long>> res;
   for (long long i = 2; i * i <= N; i++)
   {
      if (N % i != 0)
         continue;
      long long ex = 0;
      while (N % i == 0)
      {
         ex++;
         N = N / i;
      }
      res.push_back({i, ex});
   }
   if (N != 1)
      res.push_back({N, 1});
   return res;
}
int main(void)
{
   long long A, B;
   cin >> A >> B;
   vector<pair<long long, long long>> PA = prime(A);
   vector<pair<long long, long long>> PB = prime(B);
   map<long long, long long> result;
   for (int i = 0; i < PA.size(); i++)
   {
      result[PA[i].first]++;
   }
   for (int i = 0; i < PB.size(); i++)
   {
      result[PB[i].first]++;
   }
   long long count = 1;
   for (auto ans : result)
   {
      if (ans.second == 2)
         count++;
   }
   cout << count << endl;
   return 0;
}
