import java.util.Scanner;

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
   val charray = sc.next().toString().toCharArray()
    if(charray[0] == charray[1] && charray[1] == charray[3] && charray[2] == charray[1]){
        println("No")
    }else if(charray[0] == charray[1]) {
        if (charray[2] == charray[3]) {
            println("Yes")
        }else{
            println("No")
        }
    }else if(charray[0] == charray[2]){
        if(charray[1] == charray[3]){
           println("Yes")
        }else{
            println("No")
        }
    }else if(charray[0] == charray[3]){
        if(charray[1] == charray[2]){
            println("Yes")
        }else{
            println("No")
        }
    }else{
        println("No")
    }
}