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

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b;
    scan(a, b);
    auto cd = common_divisers(a, b);
    long cnt;
    foreach (i; iota(cd.length))
    {
        bool disjoint = true;
        foreach (j; iota(1, i))
        {
            disjoint = disjoint && (cd[i] % cd[j]);
        }
        if(disjoint)
            cnt++;
    }
    cnt.writeln();
}

auto divisers(long t)
{
    auto ret = new long[](0);
    long iter = 1;
    while (iter ^^ 2 <= t)
    {
        if (t % iter == 0)
        {
            ret ~= iter;
            ret ~= t / iter;
        }

        iter++;
    }
    ret.sort();
    return ret;
}

auto common_divisers(long a, long b)
{
    auto a_divs = a.divisers();
    auto b_divs = b.divisers();
    auto common_set = new long[](0);
    long a_iter, b_iter;
    while (a_iter < a_divs.length && b_iter < b_divs.length)
    {
        if (a_divs[a_iter] == b_divs[b_iter])
        {
            common_set ~= a_divs[a_iter];
            a_iter++, b_iter++;
        }
        else if (a_divs[a_iter] < b_divs[b_iter])
            a_iter++;
        else
            b_iter++;
    }
    return common_set;
}

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