S = input() n = len(S) cnt = [0] * 26 ans = 0 for i, s in enumerate(S): p = ord(s) - 65 ans += cnt[p] * (n - 1 - i) cnt[p] += 1 for c in cnt: ans -= c * (c - 1) * (c - 2) // 6 print(ans)