#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; string s; cin >> s; bool non_change = false; vector single; int ans = 0; for (int i = 0; i < n - 1; i++) { if (s[i] == 'B' && s[i + 1] == 'B') { non_change = true; } else if (s[i] == 'B') { single.push_back(i + 1); } else if (s[i + 1] == 'B') { single.push_back(i); } else { ans++; } } ans += non_change; sort(single.begin(), single.end()); single.erase(unique(single.begin(), single.end()), single.end()); ans += single.size(); cout << ans << "\n"; }