string@S;ll a=0,b[26]={},c[26]={},d[26]={},s=0,n;REP(i,S.size())n=S[i]-'A',d[n]+=s-c[n],c[n]+=b[n],s+=b[n],b[n]++;rep[d](e,26)a+=e;wt(a);