module CharMap = Map.Make (Char)

let () =
  let s = read_line () in
  let m =
    Array.fold_left (fun m c ->
      CharMap.add c
        (1 + try CharMap.find c m with Not_found -> 0) m) CharMap.empty @@
    Array.init (String.length s) (String.get s) in
  print_endline @@ if 
    CharMap.cardinal m = 2 &&
    snd (CharMap.min_binding m) = snd (CharMap.max_binding m)
  then "Yes"
  else "No"