#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007
ll gcd (ll x, ll y){
	ll r = x % y ;
	if(r == 0) return y ;
	return gcd(y, r) ;
}
bool isprime(ll x){
	ll s = sqrt((double) x) ;
	for(ll i = 2; i <= s ; i++){
		if(x % i == 0) return false ; 
	}
	return true ;
}
int main (){
	ll a, b ;
	cin >> a >> b ;
	ll k = gcd(a, b) ;
	ll s = sqrt((double)k) ;
	vector<ll> y ;
	for(ll i = 1; i <= s; i++){
		if(k % i == 0){
			y.push_back(i) ;
			if(i != k/i){
				y.push_back(k/i) ;
			}
		}
	}
	sort(y.begin(), y.end()) ;
	ll num = y.size() ;
	ll ans = 0 ;
	rep(i, num){
		if(isprime(y[i])) ans++ ;
	}
	cout << ans << endl ;
}
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % 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;
}
// using namespace atcoder;
void Main()
{
    ll A, B;
    cin >> A >> B;

    ll gcd = GCD(A, B);
    auto primes = prime_factorize(gcd);
    put(primes.size() + 1);
}
signed main(){ Main();return 0;}