import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main implements Runnable{ public static void main(String[] args) { new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start(); } 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); } public 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