#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main() { ll n, cnt = 0; string s, tmp; cin >> n >> s; for (int i = 0; i < n-1; i++){ tmp = s.substr(i, 3); if (tmp == "BAB") cnt++; else if (tmp == "BBA" && s[i+3] == 'B') cnt++; else if (i >= 1 && tmp == "ABB" && s[i-1] == 'B') cnt++; } cout << s.size() - 1 - cnt << endl; }