#include using namespace std; int main() { int N; cin >> N; string S; cin >> S; int ret = 0; int res = 0; int sub = 0; for(int i = 0; i + 1 < N; i++) { ret += S[i] == 'A' or S[i + 1] == 'A'; res |= S[i] == 'B' and S[i + 1] == 'B'; } for(int i = 0; i + 2 < N; i++) { sub += S[i] == 'B' and S[i + 1] == 'A' and S[i + 2] == 'B'; } cout << ret + res - sub << endl; }