import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)
  val s = sc.next

  val chs = s.split("(?<=.)").sorted

  val judge =
    chs(0) == chs(1) &&
    chs(2) == chs(3) &&
    chs(1) != chs(2)

  val res = if(judge) "Yes" else "No"

  println(res)

}
