import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.next()
    var l = Array<Char>(2, { s[0] })
    var count = Array<Int>(2, { 1 })
    var ok = true
    for (i in 1..3) {
        if (l[0] == s[i]) {
            count[0] += 1
        } else {
            if (l[1] == s[0]) {
                l[1] = s[i]
            } else if (l[1] == s[i]) {
                count[1] += 1
            } else {
                ok = false
            }
        }
    }
    if (count[0] != 2 || count[1] != 2) {
        ok = false
    }
    if (ok) {
        println("Yes")
    } else {
        println("No")
    }
}