import java.util.*

fun main(args: Array<String>) {
    var result :Int = 0

    val n = readLine()!!

    for(moji in n){
        if(moji == 'A') result += 1
        else result -= 1
    }

    when (result){
        -3 -> print("No")
        3 -> print("No")
        else -> print("Yes")
    }

}