'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(n => Number(n));
  const gcd = (x, y) => y === 0 ? x : gcd(y, x%y)
  const G = gcd(...inp)

  let arr = [1]
  for (let i = 2; i <= G; i++) {
    if ((inp[0] % i === 0) && (inp[1] % i === 0)) {
      let isSO = true
      for (let j = 1; j < arr.length; j++) {
        if (gcd(arr[j], i) !== 1) {
          isSO = false
          break;
        }
      }
      if (isSO) arr.push(i)
    }
  }
  console.log(arr.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
