#include #define int long long 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<<1)+(x<<3)+(ch&15); ch=getchar(); } return x*f; } inline void write(int x) { if(x<0) { putchar('-'); x=-x; } if(x>9)write(x/10); putchar(x%10+'0'); return; } char s[100010]; vectormp[200010]; int ans,f[100010][4]; inline void dfs(int pos,int fa) { bool fg=(s[pos]=='w'); f[pos][fg]=1; for(auto to:mp[pos]) { if(fa==to)continue; dfs(to,pos); for(int i=0;i<4;++i)ans+=f[pos][i]*f[to][3-i],f[pos][i]+=f[to][i]; if(fg)for(int i=0;i<2;++i)f[pos][i+2]+=f[to][i]; } } signed main() { int n=read(); scanf("%s",s+1); for(int i=1;i