let factors : int -> int list = fun n ->
  let rec loop i n count =
    if n mod i == 0 then
      loop i (n / i) (count + 1)
    else
      if count <> 0 then
        i :: loop (i + 1) n 0
      else
        if i > n then []
        else
          loop (i + 1) n 0
  in
  loop 2 n 0

let rec print_int_list = function
    [] -> ()
  | (x :: xs) ->
     print_int x;
     print_char ' ';
     print_int_list xs

let rec merge = function
    ([], _) -> []
  | (_, []) -> []
  | (x::xs, y::ys) ->
     if x = y then
       x :: merge (xs, ys)
     else if x < y then
       merge (xs, y::ys)
     else
       merge (x::xs, ys)

let () =
  let (a, b) = Scanf.sscanf (input_line stdin) "%d %d" (fun a b -> (a, b)) in
  let facta = factors a in
  let factb = factors b in
  let ans_l  = 1 :: merge (facta, factb) in
  let ans = List.length ans_l
  in
  print_int ans;
  print_newline ()
