fun main(args: Array<String>) {
    var n = readLine()!!.toString()
    println(
        if (n.count { it == n[0] } == 4) "No"
        else if (n[0] == n[1] && n[2] == n[3]) "Yes"
        else if (n[0] == n[2] && n[1] == n[3]) "Yes"
        else if (n[0] == n[3] && n[1] == n[2]) "Yes"
        else "No"
    )
}