Problem:
Score : 400 points

Problem Statement

Given are positive integers A and B.

Let us choose some number of positive common divisors of A and B.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

Definition of common divisor

An integer d is said to be a common divisor of integers x and y when d divides both x and y.

Definition of being coprime

Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.

Definition of dividing

An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x.

Constraints

All values in input are integers.

1 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of divisors that can be chosen to satisfy the condition.

Sample Input 1

12 18

Sample Output 1

3

12 and 18 have the following positive common divisors: 1, 2, 3, and 6.

1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

1 and 2019 have no positive common divisors other than 1.

Solution in Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::{input, fastout};
use num::Integer;
use std::collections::HashMap;
// use itertools::*;


fn gcd<T: Integer+Copy>(x: &T, y: &T) -> T {
  if y == &T::zero() {
    *x
  } else {
    let t = *x % *y;
    gcd(y, &t)
  }
}

fn prime_factorization(mut x: u64) -> HashMap<u64, u64> {
  let mut map = HashMap::new();
  if x % 2 == 0 {
   while x % 2 == 0 {
     *map.entry(2).or_insert(0) += 1; 
     x /= 2;
   }
  }
  for d in (3..).step_by(2) {
    if x == 1 {
      break;
    }
    if x < d * d {
      map.entry(x).or_insert(1);
      break;
    }
    while x % d == 0 {
      *map.entry(d).or_insert(0) += 1; 
      x /= d;
    }
  }
  map
}

#[fastout]
fn main() {
  input!{
    a: u64,
    b: u64
  };
  let gcd_ab = gcd(&(a as u64), &(b as u64));
  let pf = prime_factorization(gcd_ab);
  println!("{}", pf.len() + 1);
}
*/

fn main() {
    let exe = "/tmp/bin76F10FC2";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";