#include using namespace std; int test( int N, string S ) { set st; for( int i = 0; i < N - 1; i++ ) { string s = S; s[i] = 'B'; s[i + 1] = 'B'; st.insert( s ); } return st.size(); } int main() { int N; string S; cin >> N >> S; int ans = 0, f = 0; for( int i = 0; i < N - 1; i++ ) { if( i == 0 ) { if( S.substr( 0, 2) == "BB" ) { ans = 1; f = 1; } else ans = 1; } else { if( S.substr( i, 2 ) == "BB" ) { if( f == 0 ) { ans++; f = 1; } } else ans++; if( S.substr( i - 1, 3 ) == "BAB" ) ans--; } } cout << ans << endl; }