#include using namespace std; #define rep(i,n) for (ll i = 0; i < n; ++ i) #define all(x) (x).begin(),(x).end() using ll = long long ; using P = pair; using PP = pair; using vi = vector; using vb = vector; using vp = vector

; using vii = vector; const ll INF = (1<<30); const int inf = 1001001001; const int dx[4]={1,-1,0,0}; const int dy[4]={0,0,1,-1}; const ll mod=998244353; int main(){ int n; string s; cin >> n >> s; int nn = n-1; bool K = false; rep(i,n-1){ if(s[i] == s[i+1] && s[i] =='B') {--nn; K =true;} else if(i+2 != n && s[i] == s[i+2] && s[i] =='B') --nn; } if(K) ++nn; cout<