S=input() DP1=[0]*26 DP2=[0]*26 ANS=0 for s in S: x=ord(s)-65 ANS+=sum(DP2)-DP2[x] DP2[x]+=DP1[x] DP1[x]+=1 print(ANS)