#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; string S; cin >> S; int bbcnt = 0; rep(i, N - 1) { if (S.substr(i, 2) == "BB") { bbcnt++; } } int ans = N - 1 - max(0, bbcnt - 1); rep(i, N - 2) { if (S.substr(i, 3) == "BAB") { ans--; } } cout << ans << '\n'; return 0; }