import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.next().toCharArray()
    var first = a[0]
    var second = 'A'
    var firstC = 0
    var secondC = 0
    var check = false
    for(i in a){
        if(i != first && !check) {
            second = i
            check = true
        }
        if(i == first) firstC++
        else if(i == second) secondC++
    }
    if(firstC === 2 && secondC === 2) println("Yes")
    else println("No")
}