object Main extends App {
  val S = io.StdIn.readLine()
  val map = scala.collection.mutable.Map.empty[String, Int]
  S.foreach { char =>
    val charStr = char.toString
    if (map.contains(charStr)) {
      val count = map(charStr)
      map.put(charStr, count + 1)
    } else {
      map.put(charStr, 1)
    }
  }

  val keysSize = map.keys.size

  if (keysSize == 2 && map.values.forall(_ == 2)) println("Yes")
  else println("No")
}