import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Classes = Tuple!(long, "number", long, "person");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a, b;
    scan(a, b);
    intersection(a.prime_factorization, b.prime_factorization).length.writeln();
}

auto factorization(long a)
{
    auto factor = new long[](0);
    auto limit = cast(long) sqrt(cast(float) a);
    foreach (i; iota(limit))
    {
        long tmp = i + 1;
        if (a % tmp == 0)
        {
            factor ~= tmp;
            if (tmp != a / tmp)
                factor ~= a / tmp;
        }
    }
    factor.sort();
    return factor;
}

auto prime_factorization(long a)
{
    auto factor = a.factorization();
    auto p_factor = [1L];
    foreach (i; iota(1, factor.length))
    {
        bool is_prime = true;
        foreach (j; iota(1, i))
            is_prime &= (factor[i] % factor[j] != 0);
        if (is_prime)
            p_factor ~= factor[i];
    }
    return p_factor;
}

auto intersection(T)(T a, T b)
{
    auto retary = new T(0);
    foreach (i; iota(a.length))
    {
        foreach (j; iota(b.length))
        {
            if (a[i] == b[j])
            {
                retary ~= a[i];
                break;
            }
        }
    }
    return retary;
}
