"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 getPrimeFactors = n => {
    let result = [1];

    if (n === 1) {
        return [1];
    }

    let init = 2;

    while ( n !== 1 ) {
        
        let i = init;
        
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                result.push(i)
                n /= i;
                break;
            }
            i++;
        }
        
        init = i;
    }
    
    return result;
}

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(getPrimeFactors(gcd))];
    
    let answer = primeFactors.length;
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
