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