#include // debug #ifdef LOCAL #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif // #include "atcoder/all" using namespace std; using ll = long long; using ld = long double; void solve() { int N; string S; cin >> N >> S; bool no_change = false; int ans = 0; for (int i = 0; i < N - 1; i++) { if (S[i] == 'B' && S[i + 1] == 'B') { if (!no_change) { ans++; no_change = true; } continue; } if (S[i + 1] == 'A') { ans++; continue; } if (i == 0) { ans++; continue; } if (S[i - 1] == 'A') ans++; } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }