import java.util.Scanner
import scala.collection.mutable

object Main {

  def solve(sc: Scanner): String = {
    val s = sc.next()
    val mm = mutable.Map(s.distinct.map { c => c -> 0 }.toMap.toSeq: _*)
    s.indices.foreach { i =>
      mm(s(i)) += 1
    }
    val countList = mm.toList.map(_._2)
    if (countList == List(2, 2)) "Yes" else "No"
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}
