import scala.math._

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

  val map = s.foldLeft(Map.empty[Char, Int])((acc, v) => acc.get(v) match {
    case Some(vv) => acc.updated(v, acc(v) + 1)
    case _ => acc + (v -> 1)
  })

  val ans = if (map.size == 2 && map.head._2 == 2) "Yes" else "No"

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)
}