#include using namespace std; int main() { int N; string S; cin >> N >> S; int ans = 0,f = 0; for(int i = 0; i+1 < N; i++) { if(S[i] == 'B' && S[i+1] == 'B') { f = 1; continue; } else if(i && S[i-1] == 'B' && S[i+1] == 'B') { continue; } else { ans++; } } cout << ans+f << endl; }