#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

template <typename TYPE>
struct GCD_template
{
    static
    TYPE gcd(TYPE a, TYPE b) {
        if (b == 0) return a;
        else return gcd(b, a % b);
    }
    static
    TYPE extgcd(TYPE a, TYPE b, TYPE& x, TYPE& y) {
        if (b == 0) {
            x = 1; y = 0; return a;
        } else {
            TYPE d = extgcd(b, a % b, y, x);
            y -= a / b * x;
            return d;
        }
    }
    static
    TYPE lcm(TYPE x, TYPE y) {
        return x / gcd(x, y) * y;
    }
};
using GCD = GCD_template<long long>;

template <typename TYPE>
struct Prime_template
{
    TYPE N;
    bool isPrime;
    std::vector<TYPE> factor;
    std::map<TYPE, TYPE> factorized;
    Prime_template(TYPE n)
    :N(n), isPrime(false)
    {
        factor.push_back(1);
        if (N>1) factor.push_back(N);
        for (TYPE i = 2; i*i <= N; ++i) {
            TYPE ex = 0;
            if (N % i == 0) {
                factor.push_back(i);
                TYPE other = N / i;
                if (other != i) factor.push_back(other);
            }
        }
        std::sort(factor.begin(), factor.end());
        isPrime = factor.size() == 2U;
    
        for (TYPE i = 2; i*i <= n; ++i) {
            TYPE ex = 0;
            if (n % i == 0) {
                while (n % i == 0) {
                    ++ex;
                    n /= i;
                }
                factorized.insert(std::make_pair(i, ex));
            }
        }
        if (n != 1) factorized.insert(std::make_pair(n, 1));
    }
};
using Prime = Prime_template<long long>;

void solve() {
    ll a, b; cin >> a >> b;
    auto g = GCD::gcd(a, b);
    auto p = Prime(g);
    cout << p.factorized.size() + 1 << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 384