function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);

    var aa = 0;flag = true;
    for(var i = 1;i <= n;i++){
        if(input[i] == "A")
            aa++;
        else{
            if(aa == 0){
                flag = false
                break;
            }
            aa--;
        }
   }
   if(flag && aa == 0)
       console.log("YES");
   else
       console.log("NO");
 
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));