#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 

int main() {
  ll a,b;
  cin >> a  >> b;
  
  vector<ll> ay;
  vector<ll> by;
  
  for(ll i = 1; i <= sqrt(a);i++){
    if(a%i == 0){
      ay.push_back(i);
      if(i != a/i){
        ay.push_back(a/i);
      }
    }
  }
  for(ll i = 1; i <= sqrt(b);i++){
    if(b%i == 0){
      by.push_back(i);
      if(i != b/i){
        by.push_back(b/i);
      }
    }
  }
  //cout << ay.size() << " " << by.size() << endl;
  vector<ll> kys;
  for(int i = 0;i<ay.size();i++){
    for(int j = 0;j<by.size();j++){
      
      if(ay[i]==by[j]){
        kys.push_back(ay[i]);
        //cout << ay[i] << " " << by[j]<< endl;
      }
    }  
  }    
  
  int res = 0;
  int flg = 0;
  sort(kys.begin(),kys.end(),greater<ll>());
  for(int i = 0;i<kys.size();i++){
    flg = 0;
    for(int j = i+1;j<kys.size();j++){
      if(__gcd(kys[i],kys[j]) != 1){
        flg = 1;
        break;
      } 
    }
    if(flg == 0){res++;}
  }
  
  
  cout << res;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

vector<pair<ll, ll> > prime; 

void prime_fuct(ll x){
    for (ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            pair<ll, ll> p = make_pair(i, 0);
            while (x % i == 0){
                x /= i;
                p.second++;
            }
            prime.push_back(p);
        }
    }
    if(x > 1){
        pair<ll, ll> p = make_pair(x, 1);
        prime.push_back(p);
    }
}

ll gcd(ll  x, ll y){
    if(y == 0) return x;
    else  return gcd(y, x % y);
}




int main(){
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);
    prime_fuct(n);
    ll ans = (ll)prime.size() + 1;
    cout << ans << endl;
}