"use strict";
    
const divisor = num => {
    let results = [];
    
    for(let i=1; i<=num; i++) {
        if( (num % i === 0) ) {
            results.push(i);
        }
    }
    
    return results;
}

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

const getAllFactorsFor = remainder => {
    var factors = [], i;

    for (i = 2; i*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 + 1;
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
