#include using namespace std; int main () { int N; cin >> N; string s; cin >> s; s = "B" + s + "B"; int ans = 0; for (int i = 0; i <= N; i ++) { if (s[i] == 'A' || s[i + 1] == 'A') { ans ++; } } for (int i = 0; i < N; i ++) { if (s.substr(i, 3) == "BAB") { ans --; } } cout << ans << endl; }