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

#define ll long long

ll GCD(ll a, ll b) {
  return a % b ? GCD(b, a % b): b;
}


vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll,ll>> res;
    for (ll a = 2; a * a <= n; ++a) {
        if (n % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (n % a == 0) {
            ++ex;
            n /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (n != 1) res.push_back({n, 1});
    return res;
}

int main() {
  ll A, B;
  cin >> A >> B;
  
  ll g = GCD(max(A, B), min(A,B));
  
  
  vector<pair<ll,ll>> vec_f = prime_factorize(g);
  
  cout << vec_f.size() + 1 << endl;
  
  
  
  
  
}
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 10000000

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

    if(a==b&&a==1){
        cout << 1 << endl;
        return 0;
    }
    if(a<b){
        swap(a,b);
    }
    ll c=a;
    ll i;

    for(i=2;i*i<=c;++i){
        if(c%i!=0){
            continue;
        }
        while(c%i==0){
            c/=i;
        }
        num.push_back(i);
    }
    if(c!=1){
        num.push_back(c);
    }
    ssort(num);

    ll count=1;
    rep(i,num.size()){
        if(b>=num[i]){
            if(b%num[i]==0){
                count++;
            }
        }
    }
    cout << count << endl;
}