#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 int main(){ int n; cin>>n; string S; cin>>S; vector pos; long long cs = 0,cc = 0; rep(i,n){ if(S[i]=='C'){ cs -= cc; cs += i; cc++; } if(S[i]=='?'){ pos.push_back(i); } } long long ans = cs; reverse(pos.begin(),pos.end()); rep(i,pos.size()){ cs += pos[i]; cs -= cc; cc++; ans = max(ans,cs); } cout<