def solve(S): ans = 0 ch = {c: 0 for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"} N = len(S) for i in range(N): ch[S[i]] += 1 if ch[S[i]] >= 2: ans += (ch[S[i]] - 1) * (N - i - 1) return ans S = input() print(solve(S))