"use strict";
    
const getGcd = (a, b) => {
  return a ? getGcd(b % a, a) : b;
}

const getAllFactorsFor = remainder => {
    var factors = [1], i;
    remainder = Math.sqrt(remainder);

    for (i = 2; i <= remainder; i++) {
        while ((remainder % i) === 0) {
            factors.push(i);
            remainder /= i;
        }
    }

    return factors;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    // 最大公約数を見つける
    const gcd = getGcd(A, B);

    // 最大公約数の素因数の数が答えになる
    const primeFactors = new Set(getAllFactorsFor(gcd));
    
    let answer = primeFactors.size;
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
