# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>

using namespace std;

#define int long long
bool isprime(int num){ // 判断是否是素数
    if(num==1){
        return false;
    }
    if(num==2)
        return true;
    if(num%2==0)
        return false;
    double sqrtNum = sqrt(num);
    for (int  i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
vector<int> v;
signed main(){
    int n,m;
    cin>>n>>m;
    int temp=min(n,m);
    for(int i=1;i*i<=temp;i++){ // 求一个数的因子的模板
        if(temp%i==0){
            v.push_back(i);
            if(i*i!=temp){
                v.push_back(temp/i);
            }
        }
    }
    int ans=0;
    int t=max(n,m);
    for(int i=0;i<v.size();i++){
        if(t%v[i]==0&&isprime(v[i]))
            ans++;
    }
    cout<<ans+1;
    return 0;
}