var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift() - 0;
var a = 0;
for (var i = 0; i < n; i++) {
   (arr[i] == "A") ? a++ : a--;
   if (a < 0) break;
}
console.log((a == 0) ? "YES" : "NO");