object Main {

  import scala.collection.mutable

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next

    var chars = mutable.HashMap.empty[Char, Int]
    for (c <- S) {
      if (chars.contains(c)){
        chars(c) += 1
      } else {
        chars += c -> 1
      }
    }
    var res = true
    for (cs <- chars) {
      if (cs._2 != 2) {
        res = false
      }
    }
    if (chars.size != 2) {
      res = false
    }

    if(res){
      println("Yes")
    } else {
      println("No")
    }
  }
}