import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    auto fa = factorize(A);
    auto fb = factorize(B);
    return fa.keys.filter!(a => a in fb).count + 1;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


long[long] factorize(long n) {
    long[long] counter;
    const sqN = n.to!float.sqrt.ceil.to!long;

    while ((n & 1) == 0) {
        counter[2]++;
        n /= 2;
    }
    for (long i = 3; i < sqN + 1; i += 2) {
        while (n % i == 0) {
            counter[i]++;
            n /= i;
        }
        if (n == 1)
            break;
    }
    if (n != 1)
        counter[n] = 1;

    return counter;
}