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);

    long g = gcd(a, b);
    long cnt = 1;
    for (long i = 2; i * i <= g; i++)
    {
        if (g % i == 0)
        {
            cnt++;
            while (g % i == 0)
            {
                g /= i;
            }
        }
    }
    if (g != 1)
    {
        cnt++;
    }
    writeln(cnt);
}
