import sys input = lambda: sys.stdin.readline().rstrip() ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def main(): # 入力 S = input() N = len(S) # 計算・出力 prev = {s:0 for s in ALPHABET} next = {s:0 for s in ALPHABET} for s in S: next[s] += 1 ans = 0 for i, s in enumerate(S): next[s] -= 1 ans += prev[s] * (N-i-1 - next[s]) prev[s] += 1 print(ans) if __name__ == "__main__": main()