let () =
  let rec charlist_of_string str i n =
    if i = n then [] else str.[i] :: charlist_of_string str (i+1) n in
  Scanf.scanf "%s\n" @@ fun s ->
  let slist = List.fast_sort compare 
      (charlist_of_string s 0 (String.length s)) in
  let str = List.fold_left (fun str c -> str ^ Char.escaped c) "" slist in
  Printf.printf "%s\n"
    (if str.[0] = str.[1] && str.[1] <> str.[2] && str.[2] = str.[3]
     then "Yes" else "No")