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

long[] commonDivisor(long x, long y) {
    import std.numeric;
    long d = gcd(x, y);
    long[] result;
    foreach (i; 1 .. d+1) {
        if (d % i == 0) result ~= i;
    }
    return result;
}

bool isPrime(long x) {
    if (x < 2) return false;
    if (x == 2) return true;
    if (x % 2 == 0) return false;
    for (long i = 3; i * i <= x; i += 2) {
        if (x % i == 0) return false;
    }
    return true;
}

void main() {
    long[] tmp = readln.chomp.split.to!(long[]);
    long a = tmp[0], b = tmp[1];
    long[] cd = commonDivisor(a, b);
    long cnt = 1;
    foreach (x; cd) {
        if (isPrime(x)) ++cnt;
    }
    cnt.writeln;
}