let filter n =
  match n with
  | 1 ->
      true
  | 2 ->
      true
  | n ->
      if n < 2 || n mod 2 = 0 then false
      else
        let rec f i =
          if float_of_int i > sqrt (float_of_int n) then true
          else if n mod i = 0 then false
          else f (i + 2)
        in
        f 3

let common_div a b =
  let sml = min a b and lrg = max a b in
  let num = Array.init sml (fun i -> i + 1) and acc = ref [] in
  for i = 0 to sml - 1 do
    if sml mod num.(i) = 0 && lrg mod num.(i) = 0 then acc := num.(i) :: !acc
  done ;
  Array.of_list @@ List.rev !acc

let () =
  let a, b = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
  let divs = common_div a b in
  let c = ref 0 in
  Array.iter (fun n -> if filter n = true then c := !c + 1) divs ;
  print_int !c
