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

void main() {
    auto s = readln.split.map!(to!long);
    auto A = s[0];
    auto B = s[1];

    long[] X, Y;
    bool[long] st;
    long aa = A, bb = B;

    for (long a = 1; a * a <= aa; a++) {
        if (aa % a == 0) {
            X ~= a;
            while (a != 1 && aa % a == 0)
                aa /= a;
        }
    }

    if (aa > 1) X ~= aa;


    for (long a = 1; a * a <= bb; a++) {
        if (bb % a == 0) {
            Y ~= a;
            while (a != 1 && bb % a == 0)
                bb /= a;
        }
    }

    if (bb > 1) Y ~= bb;

    foreach (a; X) if (A % a == 0 && B % a == 0) st[a] = true;
    foreach (a; Y) if (A % a == 0 && B % a == 0) st[a] = true;

    auto C = st.keys.array;
    int M = C.length.to!int;
    long ans = 1;

    foreach (mask; 0..(1<<M)) {
        long[] lst;
        foreach (i; 0..M) {
            if (mask & (1 << i)) lst ~= C[i];
        }
        bool ok = true;
        foreach (i; 0..M) {
            foreach (j; i+1..M) {
                if (gcd(C[i], C[j]) != 1) {
                    ok = false;
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) ans = max(ans, mask.popcnt);
    }

    ans.writeln;
}
