
function Main(input) {
  input = input.trim().split(" ").map(e => parseInt(e, 10));
  var A = input[0];
  var B = input[1];
  var i = 2;
  var tmpLimit = Math.sqrt(Math.min(A,B));
  var NGList = Array.from({length: tmpLimit}, () => 0);
  var v_ans = [];
  var tmp;
  whole_loop:
  while(true){
    division_loop:
    for (i = i; i <= tmpLimit; i++){
      if (NGList[i - 1] === 1) continue division_loop;
      if ( A % i === 0){
        if (B % i === 0){
          A /= i;
          B /= i;
          if (i !== v_ans[v_ans.length - 1]) v_ans.push(i);
          break division_loop;
        } else {
          A /= i;
          break division_loop;
        }
      } else {
        if (B % i === 0){
          B /= i;
          break division_loop;
        } else {
          tmp = tmpLimit / i;
          for (var j = 1; j <= tmp; j++){
            NGList[i * j - 1] = 1;
          }
          continue division_loop;
        }
      }
    }
    tmpLimit = Math.sqrt(Math.min(A,B));
    NGList.length = Math.floor(tmpLimit);
    if (i > tmpLimit) {
      if (Math.max(A, B) % Math.min(A, B) === 0){
        for (var j = 0; j < v_ans.length; j++){
          if (Math.min(A, B) % v_ans[j] === 0) break whole_loop;
        }
        v_ans.push(Math.min(A, B));
      }
      break whole_loop; 
    }
  }
  if (v_ans[v_ans.length - 1] !== 1) v_ans.push(1);
  console.log(v_ans.length);
}   

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