object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }


def solve(aaa:String): String={
  val seq = aaa.split("").takeRight(4)
  val ret = if ( seq.toSet.size == 2 && seq.filter(_ == seq(0)).size == 2){
    "Yes"
  } else {
    "No"
  }
  ret
}

}
