import sys

def input(): return sys.stdin.readline().rstrip()

from collections import defaultdict

def main():

    A=eval(input())

    len_a=len(A)

    dp=[0]*len_a

    dp[0]=1

    dd=defaultdict(int)

    dd[A[0]]+=1

    for i in range(1,len_a):

        a=A[i]

        dp[i]=i-dd[a]

        dd[a]+=1

    print((sum(dp)))



if __name__=='__main__':

    main()
import sys

def input(): return sys.stdin.readline().rstrip()

from collections import Counter

def main():

    A=eval(input())

    ac=list(Counter(A).values())

    len_a=len(A)

    ans=len_a*(len_a-1)//2

    for acc in ac:

        ans-=acc*(acc-1)//2

    print((ans+1))



if __name__=='__main__':

    main()
import sys


def input():
    return sys.stdin.readline().rstrip()


from collections import defaultdict


def main():
    A = eval(input())
    len_a = len(A)
    dp = [0] * len_a
    dp[0] = 1
    dd = defaultdict(int)
    dd[A[0]] += 1
    for i in range(1, len_a):
        a = A[i]
        dp[i] = i - dd[a]
        dd[a] += 1
    print((sum(dp)))


if __name__ == "__main__":
    main()

import sys


def input():
    return sys.stdin.readline().rstrip()


from collections import Counter


def main():
    A = eval(input())
    ac = list(Counter(A).values())
    len_a = len(A)
    ans = len_a * (len_a - 1) // 2
    for acc in ac:
        ans -= acc * (acc - 1) // 2
    print((ans + 1))


if __name__ == "__main__":
    main()

-from collections import defaultdict +from collections import Counter +    ac = list(Counter(A).values()) -    dp = [0] * len_a -    dp[0] = 1 -    dd = defaultdict(int) -    dd[A[0]] += 1 -    for i in range(1, len_a): -        a = A[i] -        dp[i] = i - dd[a] -        dd[a] += 1 -    print((sum(dp))) +    ans = len_a * (len_a - 1) // 2 +    for acc in ac: +        ans -= acc * (acc - 1) // 2 +    print((ans + 1))