import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long calc(long a, long b) {
    long g = gcd(a, b);
    bool[long] d = [g: true];
    if (g % 2 == 0) {
        d[2] = true;
        while (g % 2 == 0) g /= 2;
    }
    for (long i = 3; i * i <= g; i += 2) {
        if (g % i == 0) {
            d[i] = true;
            while (g % i == 0) g /= i;
        }
    }
    d[1] = true;
    return d.keys.length;
}

void main() {
    long a, b; scan(a, b);
    writeln(calc(a, b));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
