#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ ll N, ans=0, cntc=0, now=0, cnta=0; string S; cin >> N >> S; for (int i=0; i=0; i--){ if (S[i] == 'C') cntc++; else if (S[i] == '?'){ now -= cntc; cntc++; cnta--; now += cnta; } else cnta--; ans = max(ans, now); } cout << ans << endl; return 0; }