#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (b) return gcd(b, a%b);
    return a;
}

int div(ll n)
{
    int sq = (int)sqrt(n) + 1, cnt = 0;
    for (int i = 2; i <= sq; ++i)
    {
        if (n % i == 0)
        {
            ++cnt;
            while ((n /= i) % i == 0);
            sq = (int)sqrt(n) + 1;
        }
    }
    return cnt + (n > 1 ? 1 : 0);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    a = gcd(a, b);
    cout << div(a)+1;
    return 0;
}