object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")

    val input=io.Source.stdin.getLines().mkString("\n")
    val seq = input.split("")
    val ret = if ( seq.toSet.size == 2 && seq.filter(_ == seq(0)).size == 2){
      "Yes"
    } else {
      "No"
    }
    println(ret)
  }
}