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 = 2; i * i <= c; i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            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;
    writeln(factor_primes.length);
}
