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 times = cast(long)(sqrt(min(cast(double) a, b)));

    for (long i = 1; i * i <= a; i++)
    {
        if (a % i == 0)
        {
            if (i !in factors)
            {
                factors[i] = 0;
            }
            factors[i] += 1;
        }
    }
    for (long i = 1; i * i <= b; i++)
    {
        if (b % i == 0)
        {
            if (i !in factors)
            {
                factors[i] = 0;
            }
            factors[i] += 1;
        }
    }

    alias T = Tuple!(long, "cnt", long, "v");
    T[] cands = [];
    foreach (f, cnt; factors)
    {
        if (cnt != 2)
        {
            continue;
        }

        bool found = false;
        foreach (i, c; cands)
        {
            if (gcd(f, c.v) == 1)
            {
                cands[i].cnt += 1;
                found = true;
            }
        }
        if (!found)
        {
            cands ~= T(1, f);
        }
    }

    long max = -1;
    foreach (c; cands)
    {
        if (c.cnt > max)
        {
            max = c.cnt;
        }
    }
    writeln(max);
}
