const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const ns = line[0].split(' ').map(Number);
const a = ns[0];
const b = ns[1];

const gcd_f = (x, y) => x % y === 0 ? y : gcd_f(y, x % y);
const gcd = gcd_f(a, b);

const cd = [];
for (var i = 0; i < gcd; i++) {
  if (a % i === 0 && b % i === 0) cd.push(i);
}
cd.push(gcd);

const table = [...Array(cd.length)].map(_ => [...Array(cd.length)].map(_ => false));
for (var i = 0; i < cd.length; i++) {
  for (var j = i+1; j < cd.length; j++) {
    if (i > j) continue;
    table[i][j] = gcd_f(cd[i], cd[j]) === 1;
  }
}

const ans = [0];

for (var i = 0; i < cd.length; i++) {
  if (ans.every(x => table[x][i])) ans.push(i);
}

console.log(ans.length);
