#include #include #include #include #include #include using namespace std; #define reps(i, a, n) for (int i = (a); i < (int)(n); ++i) #define rep(i, n) reps(i, 0, n) #define ALL(x) x.begin(),x.end() #define SIZE(x) ll(x.size()) #define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf #define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf #define MOD 1000000007 //問題による #define ll long long #define F first #define S second #define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()< #define vvi vector > #define vll vector #define vvll vector > int main(){ int n; cin >> n; string s; cin >> s; int cnta = 0; int cntb = 0; s = s + 'A'; int res = 0; reps(i,1,n){ if(s[i-1] == 'B' && s[i] == 'A' && cnta == 1){ res += (cntb + 1); cnta = 1; cntb = 0; } else if(s[i-1] == 'B' && s[i] == 'A' && cnta == 0){ cnta = 1; } else if(s[i-1] == 'B'&& s[i] == 'B'){ cntb++; } else if(s[i-1] == 'A' && s[i] == 'A'){ cnta = 0; cntb = 0; } //cout << cnta << " " << cntb << " " <