import std.stdio, std.string, std.array, std.conv;

long solve(long x, long y) {
    import std.numeric;
    long d = gcd(x, y);
    long[] factors = [1];
    while (d % 2 == 0) {
        d /= 2;
        if (factors[$-1] != 2) factors ~= 2;
    }
    for (long i = 3; i * i <= d; i += 2) {
        while (d % i == 0) {
            d /= i;
            if (factors[$-1] != i) factors ~= i;
        }
    }
    if (d != 1) factors ~= d;
    return factors.length;
}

void main() {
    long[] tmp = readln.chomp.split.to!(long[]);
    long a = tmp[0], b = tmp[1];
    solve(a, b).writeln;
}