import sys import logging import math input = sys.stdin.readline logger = logging.getLogger(__name__) def read(): S = input().strip() return S, def nC2(n): return n * (n-1) // 2 def solve(S): N = len(S) count = [[0 for j in range(26)] for i in range(N)] for i in range(N): s = ord(S[i]) - ord('A') for j in range(26): count[i][j] = count[i-1][j] count[i][s] += 1 ans = 0 for i in range(1, N): s = ord(S[i]) - ord('A') for j in range(26): if j == s: continue if count[i-1][j] >= 2: ans += nC2(count[i-1][j]) return ans if __name__ == "__main__": inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))