#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

int main() {
    ll A, B;
    cin >> A >> B;
    vector<ll> num_A;
    vector<ll> num_B;
    vector<ll> num;
    num_A.push_back(1);
    num_B.push_back(1);
    for(int i = 2; i <= sqrt(A); i++){
        if(A % i == 0){
            while(A % i == 0){
                A = A / i;
            }
            num_A.push_back(i);
        }
    }
    num_A.push_back(A);
    sort(num_A.begin(),num_A.end());
    num_A.erase(unique(num_A.begin(), num_A.end()), num_A.end());

    for(int i = 2; i <= sqrt(B); i++){
        if(B % i == 0){
            while(B % i == 0){
                B = B / i;
            }
            num_B.push_back(i);
        }
    }
    num_B.push_back(B);
    sort(num_B.begin(),num_B.end());
    num_B.erase(unique(num_B.begin(), num_B.end()), num_B.end());

    for(int i = 0; i < num_A.size(); i++){
        for(int j = 0; j < num_B.size(); j++){
            if(num_A[i] == num_B[j]){
                num.push_back(num_A[i]);
            }
        }
    }

    cout << num.size() << endl; 
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> x >> y;
	ll ans=1;
	n=x;
	for(i=2;i*i<=x;i++)
	{
		if(n%i==0 && y%i==0)
			ans++;
		while(n%i==0)
			n/=i;
	}
	if(n>1 && y%n==0)
		ans++;

	cout<<ans<<endl;
}