object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val S = sc.next()
  val (a, b) = S.toSeq.sorted.unwrap.splitAt(2)
  println(if (a.head == a.last && b.head == b.last && a.head != b.head) "Yes" else "No")
}
