import sys

sys.stdin = open("strange.in", "r")
sys.stdout = open("strange.out", "w")

s = input()
n = len(s)
prev = 0
prevc = None
cur = 0
curc = None

singles = [0] * 26
pairs = dict()

def relax():
    if curc != None:
        singles[ord(curc) - ord('a')] = max(singles[ord(curc) - ord('a')], cur)

    if prevc != None:
        if (prevc, curc) not in pairs:
            pairs[(prevc, curc)] = set()
        for i in range(1, prev + 1):
            for j in range(1, cur + 1):
                pairs[(prevc, curc)].add((i, j))


for i in range(n):
    if s[i] == curc:
        cur += 1
    else:
        relax()

        prevc, prev = curc, cur
        cur = 1
        curc = s[i]

relax()

ans = sum(singles) + sum(map(lambda x : len(x), pairs.values()))

print(ans)