import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { long curtime=System.currentTimeMillis(); new Main().run(); System.err.println(System.currentTimeMillis()-curtime); } long ans=0; int totW=0,totC=0; void dfs(int cur,int par,ArrayList[] g,int[] c,int[] w,char[] cs) { if(cs[cur]=='c')++c[cur]; else ++w[cur]; for(int dst:g[cur]) { if(dst==par)continue; dfs(dst,cur,g,c,w,cs); c[cur]+=c[dst]; w[cur]+=w[dst]; } if(cs[cur]=='w') { for(int dst:g[cur]) { if(dst==par)continue; ans+=(long)c[dst]*(totW-w[dst]-1); } } if(cs[cur]=='w')ans+=(long)(totC-c[cur])*(w[cur]-1); } void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt();//3<=N<=1e5 char[] cs=sc.next().toCharArray(); ArrayList[] g=new ArrayList[N]; for(int i=0;i(); for(int i=0;i