fun main(args: Array<String>) {
    // Your code here!
    
    val S: String = readLine()!!
    var l = mutableMapOf<Char, Int>()
    for (item in S) {
        if (l.containsKey(item)) {
            l[item] = l[item]!! + 1
        } else {
            l.put(item, 1)
        }
    }

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