s=input() ans=0 for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": co=0 for j in s: if j==i: co+=1 else: ans+=co*(co-1)//2 print(ans)