function getPrimeFactors(n) {
    if (n < 2) return [];
    if (n === 2 || n === 3 || n === 5) return [n];
    if (n % 2 === 0) return [2].concat(getPrimeFactors(n/2));
    if (n % 3 === 0) return [3].concat(getPrimeFactors(n/3));
    if (n % 5 === 0) return [5].concat(getPrimeFactors(n/5));
    let prime = 7;
    let step = 4;
    const limit = Math.sqrt(n);
    while (prime <= limit) {
      if (n % prime === 0) return [prime].concat(getPrimeFactors(n/prime));
      prime += step;
      step = 6 - step;
    }
    return [n];
};

function main(input) {
    const args = input.split(' ')
    const n1 = args[0], n2 = args[1]
    const a = Array.from(new Set(getPrimeFactors(n1)))
    const b = Array.from(new Set(getPrimeFactors(n2)))
    console.log(a.map( x => b.find( y => x == y)).filter(Boolean).length + 1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
