from collections import defaultdict s = input() ans = 0 t = 0 dd = defaultdict(int) for c in s: k = 0 dd[c] += 1 if 2 <= dd[c]: t += dd[c] - 1 k = (dd[c] * (dd[c] - 1)) // 2 ans += t - k print(ans)