s = input() dc = set((k for k in s)) c = 0 for _ in range(len(s)): t = s[0] s = s[1:] n = s.count(t) + 1 if n > 1: n = s.index(t) k = s[n:] for i in dc: if i != t and i in k: c += k.count(i) print(c)