S = list(input()) DP = [0]*26 ans = 0 for s in S: i = ord(s)-ord('A') DP[i]+=1 for j in range(26): if i!=j: ans+=DP[j]*(DP[j]-1)//2 print(ans)