let s = read_line ()
let b = if s.[0] = s.[1] then s.[0] <> s.[2] && s.[2] = s.[3]
  else if s.[0] = s.[2] then s.[0] <> s.[1] && s.[1] = s.[3]
  else if s.[0] = s.[3] then s.[0] <> s.[1] && s.[1] = s.[2]
  else false
let _ = print_endline @@ if b then "Yes" else "No"