let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let rec factorize acc i n =
  if n <= 1 then acc
  else if n < i * i then n :: acc
  else if n mod i = 0 then factorize (i :: acc) i (n / i)
  else factorize acc (i + 1) n
let factorize n =
  match factorize [] 2 n with
  | [] -> []
  | p :: ps ->
      let (acc, p, n) = List.fold_left (fun (acc, p, n) q ->
        if p = q
        then (acc, p, n + 1)
        else ((p, n) :: acc, q, 1)) ([], p, 1) ps in
      (p, n) :: acc

let () = Scanf.scanf "%d %d" @@ fun a b ->
  Printf.printf "%d\n" @@
  ( + ) 1 @@
  List.length @@
  factorize (gcd a b)

