from collections import Counter from string import ascii_uppercase from math import comb S = input() freq = Counter() ans = 0 for c in S: for a in ascii_uppercase: if a == c: continue ans += comb(freq[a], 2) freq[c] += 1 print(ans)