A = input().strip()

C = {chr(i):0 for i in range(97,123)}

n = len(A)

for i in range(n):

    C[A[i]] += 1

cnt = 0

for a in C:

    cnt += (C[a]*(C[a]-1))//2

print((1+(n*(n-1))//2-cnt))
A = input().strip()

N = len(A)

tot = 1+(N*(N-1))//2

C = {chr(i):[] for i in range(97,123)}

for i in range(N):

    C[A[i]].append(i)

cnt = 0

for a in C:

    n = len(C[a])

    cnt += (n*(n-1))//2

print((tot-cnt))
A = input().strip()
C = {chr(i): 0 for i in range(97, 123)}
n = len(A)
for i in range(n):
    C[A[i]] += 1
cnt = 0
for a in C:
    cnt += (C[a] * (C[a] - 1)) // 2
print((1 + (n * (n - 1)) // 2 - cnt))

A = input().strip()
N = len(A)
tot = 1 + (N * (N - 1)) // 2
C = {chr(i): [] for i in range(97, 123)}
for i in range(N):
    C[A[i]].append(i)
cnt = 0
for a in C:
    n = len(C[a])
    cnt += (n * (n - 1)) // 2
print((tot - cnt))

-C = {chr(i): 0 for i in range(97, 123)} -n = len(A) -for i in range(n): -    C[A[i]] += 1 +N = len(A) +tot = 1 + (N * (N - 1)) // 2 +C = {chr(i): [] for i in range(97, 123)} +for i in range(N): +    C[A[i]].append(i) -    cnt += (C[a] * (C[a] - 1)) // 2 -print((1 + (n * (n - 1)) // 2 - cnt)) +    n = len(C[a]) +    cnt += (n * (n - 1)) // 2 +print((tot - cnt))