"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 isPrime = num => {
  let result = true;
  if (num === 2) return true;
  if (num % 2 === 0) return false;

  for (let i = 0; i < num; i++) {
    if (num % i === 0 && i !== 1) {
      // 一度でもiで割り切れる場合は素数ではない&ループ離脱
      result = false;
      break;
    } else {
      result = true;
    }

    // numの平方数まで判定すれば十分なので離脱処理
    if (i > Math.sqrt(num)) break;
  }

  return result;
}

const coPrime = (a, b) => {
    return getGcd(a, b) === 1
}

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);
    
    // 約数一覧
    let gcds = divisor(gcd);
    
    let answer = 0;
    
    console.log(gcds.filter(n=> {
        for(let i=2; i<=Math.sqrt(n); i++) {
            if(n % i === 0) return false;
        }
        return true;
    }).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
