{ Free Pascal }

uses math;

function getPowerAndDivide(var n: longint; divisor: longint): longint;
var power: longint;
begin
    power := 0;
    while n mod divisor = 0 do begin
        inc(power);
        n := n div divisor;
    end;
    getPowerAndDivide := power;
end;

function check(a, b, c: longint): boolean;
begin
    check := (a * b mod c = 0) and (a * c mod b = 0) and (b * c mod a = 0);
end;

var a, b, ans, m, curA, curB, divisor, powerA, powerB: longint;

begin
    assign(input, 'numbers.in');
    reset(input);
    assign(output, 'numbers.out');
    rewrite(output);

    read(a, b);

    ans := 1;

    m := max(a, b);
    curA := a;
    curB := b;
    for divisor := 2 to m do begin
        powerA := getPowerAndDivide(curA, divisor);
        powerB := getPowerAndDivide(curB, divisor);
        ans := ans * ((powerA + powerB) - abs(powerA - powerB) + 1);
    end;

    if (check(a, a, b)) then
        dec(ans);
    if (check(a, b, b)) then
        dec(ans);

    writeln(ans);
end.
