var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var l1 = o.getArray(0);
    var A = l1[0];
    var B = l1[1];

    var x, y;
    if (A >= B) {
        x = A;
        y = B;
    } else {
        x = B;
        y = A;
    }

    var num = gcd(x, y);
    var result = factorize(num);
    return result.length + 1;
}

function factorize(num) {
    var result = [];
    for(var i=2; i*i<=num; i++) {
        if (num%i) continue;
        var exponents = 0;
        while(num%i === 0) {
            num = num / i;
            exponents++;
        }
        result.push({base: i, exponents: exponents});
    }

    if (num !== 1) result.push({base: i, exponents: 0});

    return result;
}

function gcd(x, y) {
    if (y === 0) return x;
    return gcd(y, x%y);
}