#include #define int long long using namespace std; const int N=100005; int n,ans,c[N],w[N],f[N];string s; vectorg[N]; void dfs(int u,int fa) { f[u]=fa; if(s[u-1]=='c')c[u]=1; else w[u]=1; for(int v:g[u]) { if(v==fa)continue; dfs(v,u);c[u]+=c[v];w[u]+=w[v]; } } signed main() { cin>>n>>s; for(int i=1,u,v;i>u>>v; g[u].push_back(v); g[v].push_back(u); } dfs(1,0); for(int i=1,x,y,z;i<=n;i++) { x=0;y=0;z=0; for(int v:g[i]) { if(v==f[i])continue; x+=c[v];y+=w[v];z+=c[v]*w[v]; } x+=c[1]-c[i]; y+=w[1]-w[i]; z+=(c[1]-c[i])*(w[1]-w[i]); ans+=x*y-z; } cout<