#include using namespace std; const int N=100010; using ll=long long; char s[N]; vector e[N]; ll c[N],w[N],wc[N],ww[N],r; void dfs(int u,int f){ for(int v:e[u]){ if(v==f) continue; dfs(v,u); c[u]+=c[v],w[u]+=w[v],wc[u]+=wc[v],ww[u]+=ww[v],r-=w[v]*wc[v]+ww[v]*c[v]; } r+=w[u]*wc[u]+ww[u]*c[u]; if(s[u]=='c') c[u]++,r+=ww[u]; else r+=wc[u],wc[u]+=c[u],ww[u]+=w[u],w[u]++; } int main(){ int n; scanf("%d%s",&n,s+1); for(int i=1,u,v;i