Main = input => {
  input = input.trim().split(" ");
  const a = Number(input[0]);
  const b = Number(input[1]);
  
  const gcd = ((p, q) => p === 0 ? q : gcd(q%p, p));
  
  var x = gcd(a, b);
  
  var cnt = 1;
  for (var i = 2; i*i <= x; i++) {
    if (x%i === 0) {
      cnt++;
      while (x%i === 0) {
        x /= i;
      }
    }
  }
  if (x !== 1) {
    cnt++;
  }
  
  console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));