import java.util.*

fun main(args: Array<String>) {
    val x = readLine()!!.toList()

    val map = hashMapOf<Char, Int>()

    for (c in x) {
        val now = map.getOrElse(c) {0}
        map.put(c, now + 1)
    }

    if (map.keys.size == 2 && map.values.all { it == 2 }) {
        println("Yes")
    } else {
        println("No")
    }
}