fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    var charA = s[0]
    var charB = '-'
    var charACount = 0
    var charBCount = 0
    
    for (c in s) {
        if (c == charA) {
            charACount++
            continue
        }
        if (charB == '-') {
            charB = c
            charBCount = 1
            continue
        }
        if (c == charB) {
            charBCount++
            continue
        }
        println("No")
        return
    }
    
    if (charACount == 2 && charBCount == 2) {
        println("Yes")
    } else {
        println("No")
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}
