#include #define int long long #define MAXN 100005 using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } int n,cnt1=0,cnt2=0; string s; int cc[MAXN],cw[MAXN]; vector e[MAXN]; int res=0; void dfs(int x,int y){ if(s[x]=='c'){ cc[x]=1; } if(s[x]=='w'){ cw[x]=1; } for(int v:e[x]){ if(v!=y){ dfs(v,x); cc[x]+=cc[v]; cw[x]+=cw[v]; if(s[x]=='w'){ res+=1LL*cc[v]*(cnt2-1-cw[v]); } } } if(y!=-1 && s[x]=='w') { res+=1LL*(cnt1-cc[x])*(cw[x]-1); } } signed main(){ n=read(); cin>>s; for(char c:s){ if(c=='c'){ cnt1++; } else if(c=='w'){ cnt2++; } } for(int i=0;i