import std.stdio, std.conv, std.string, std.array, std.algorithm, std.range,
    std.math, std.numeric, std.typecons;

void main()
{
    long a, b;
    readf("%d %d\n", &a, &b);

    int[long] factors;
    long[] factor_primes = [];
    long c = max(a, b);
    for (long i = 3; i * i <= c; i += 2)
    {
        bool is_prime = true;
        foreach (f; factor_primes)
        {
            if (i % f == 0)
            {
                is_prime = false;
                break;
            }
        }
        if (is_prime)
        {
            factor_primes ~= i;
        }
    }
    factor_primes ~= 1;
    factor_primes ~= 2;

    long common_factors = 0;
    foreach (f; factor_primes)
    {
        if (a % f == 0 && b % f == 0)
        {
            common_factors++;
        }
    }
    writeln(common_factors);
}
