S = list(input()) n = len(S) DP = [[0 for _ in range(26)] for _ in range(n + 1)] ans = 0 for i in range(n): idx = ord(S[i]) - ord('A') for j in range(26): if j == idx: DP[i + 1][j] = DP[i][j] + 1 else: DP[i + 1][j] = DP[i][j] for j in range(26): if j == idx: continue ans += DP[i][j] * (DP[i][j] - 1) // 2 print(ans)