import std.stdio, std.numeric, std.math;


ulong countPrimeFactors(ulong x) {
    ulong count = 0;
    auto s = cast(ulong) sqrt(cast(real) x);
    foreach (p; 2 .. s + 1) {
        if (x % p == 0) {
            ++count;
            while (x % p == 0) {
                x /= p;
            }
        }
    }
    if (x != 1) ++count; // x is a prime number
    return count;
}

unittest {
    assert(countPrimeFactors(2) == 1);
    assert(countPrimeFactors(3) == 1);
    assert(countPrimeFactors(6) == 2);
    assert(countPrimeFactors(40) == 2);
    assert(countPrimeFactors(6700417) == 1);
}

void main() {
    ulong a, b;
    readf("%d %d\n", &a, &b);
    writeln(countPrimeFactors(gcd(a, b)) + 1);
}
