S = list(input()) ans = 0 l = len(S) for i in range (0,l): # print(S[i:-1].count(S[i])) if S[i:-1].count(S[i]) >= 2 : ans += l - S.index(S[i], i+1) - 1 print(ans)