There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that

1. 1 ≤ i, j ≤ N

2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.

Input

The single input line contains S, consisting of lowercase Latin letters and digits. It is guaranteed that string S in not empty and its length does not exceed 105.

Output

Print a single number which represents the number of pairs i and j with the needed property. Pairs (x, y) and (y, x) should be considered different, i.e. the ordered pairs count.

Examples

Input

great10


Output

7


Input

aaaaaaaaaa


Output

100

Difficulty: MEDIUM
Tags: String algorithms

Starter code:

Solutions:
def main():
	dict = {}
	S = input()
	for i in range(len(S)):
		if S[i] in dict:
			dict[S[i]] += 1
		else:
			dict[S[i]] = 1
	for key in dict:
		dict[key] *= dict[key]
	print(sum(dict.values()))
main()


s = input()
l = 300 * [0]
for i in s:
	l[ord(i)] = l[ord(i)] + 1
j = 0
for i in l:
	j = j + i * (i - 1)
print(j + len(s))


S = input()
n = []
for each in S:
	if each not in n:
		n.append(each)
b = 0
for each in n:
	a = 0
	for word in S:
		if each == word:
			a += 1
	b += a ** 2
print(b)


import math

def main():
	s = input()
	d = {}
	for c in s:
		if c not in d:
			d[c] = 1
		else:
			d[c] += 1
	ans = 0
	for (a, b) in d.items():
		ans += b * b
	print(ans)
main()


n = input()
m = list(n)
p = set(m)
num = 0
for i in p:
	num += m.count(i) ** 2
print(num)


S = input()
T = [0] * 200
for e in S:
	T[ord(e)] += 1
somme = 0
for i in T:
	somme += i * i
print(somme)


s = input()
p = 0
for i in set(s):
	p += s.count(i) * s.count(i)
print(p)


s = input()
freq = []
for i in range(1000):
	freq.append(0)
for x in s:
	val = ord(x)
	freq[val] += 1
ans = len(s)
for i in range(1000):
	ans += freq[i] * (freq[i] - 1)
print(ans)


s = input()
count = {}
for c in s:
	count[c] = count.get(c, 0) + 1
l = list(count.values())
t = 0
for i in l:
	t += i * i
print(t)


from sys import stdin, stdout
from collections import Counter
from collections import defaultdict
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
s = input()
s = [i for i in s]
d = list(Counter(s).values())
ans = 0
for i in d:
	if i > 1:
		ans += i * (i + 1) - i
	else:
		ans += 1
print(ans)


n = input()
s = set(n)
count = 0
for i in s:
	count += n.count(i) ** 2
print(count)


s = input()
counts = [s.count(x) for x in set(s)]
print(sum(map(lambda x: x * x, counts)))


s = input()
t = len(s)
d = {}
for x in s:
	if x in d:
		d[x] = d[x] + 1
	else:
		d[x] = 1
k = 0
for v in d:
	k += d[v] * d[v]
print(k)


n = input()
m = list(n)
dic = {}
a = 0
for i in range(len(m)):
	if m[i] in dic:
		dic[m[i]] += 1
	else:
		dic[m[i]] = 1
for key in dic:
	if dic[key] == 1:
		a += 1
	else:
		a += pow(dic[key], 2)
print(a)


s = input()
from collections import Counter
c = Counter(s)
ans = 0
for i in c:
	ans = ans + c[i] * c[i]
print(ans)


string = list(input())
s = set(string)
cn = 0
for i in s:
	tmp = string.count(i)
	cn += tmp * tmp
	tmp = 0
print(cn)


st = input()
s = 0
for i in st:
	b = st.count(i)
	s += b * b
	st = st.replace(i, '')
print(s)


s = input()
d = {}
for c in s:
	d[c] = d.get(c, 0) + 1
t = 0
for i in d.values():
	t += i ** 2
print(t)


from collections import Counter
cnt = Counter(input())
print(sum((b * b for (a, b) in cnt.items())))


s = input()
chr_num = {}
for i in s:
	chr_num[i] = 0
for i in s:
	chr_num[i] += 1
ans = 0
for i in chr_num.values():
	ans += i ** 2
print(ans)


a = input()
b = set(a)
cnt = 0
for i in b:
	cnt += a.count(i) * a.count(i)
print(cnt)


def main():
	line = input()
	dicline = {}
	for c in line:
		if c in dicline.keys():
			dicline[c] += 1
		else:
			dicline[c] = 1
	ans = 0
	for (key, value) in dicline.items():
		ans += value ** 2
	print(ans)
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	S = listStr()
	C = dc(S)
	ans = 0
	for c in C:
		ans += pow(C[c], 2)
	return ans
print(solve())


s = input()
flags = {}
n = 0
for c in s:
	flags[c] = 0
for c in s:
	n += flags[c] * 2
	n += 1
	flags[c] += 1
print(n)


n = input()
count = 0
d = {}
for i in n:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
for i in d.values():
	count += i ** 2
print(count)


w = input()
count = 0
for i in w:
	nw = w.replace(i, '')
	c = len(w) - len(nw)
	count += int(c) ** 2
	w = nw
	if len(nw) == 0:
		break
print(count)


test_str = input()
all_freq = {}
for i in test_str:
	if i in all_freq:
		all_freq[i] += 1
	else:
		all_freq[i] = 1
ans = 0
for k in all_freq.keys():
	ans = ans + all_freq[k] * all_freq[k]
print(ans)


from math import pow
string = input()
contadores = {}
total = 0
for simbolo in string:
	contadores.setdefault(simbolo, 0)
	contadores[simbolo] += 1
for simbolo in contadores:
	total += contadores[simbolo] ** 2
print(int(total))


x = input()
count = {}
t = 0
for i in x:
	count[i] = count.get(i, 0) + 1
l = list(count.values())
for i in l:
	t += i * i
print(t)


s = input().strip()
result = 0
for ch in set(s):
	result += s.count(ch) ** 2
print(result)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(lst):
	cnt = {}
	for i in lst:
		if cnt.get(i) == None:
			cnt[i] = 1
		else:
			cnt[i] += 1
	count = 0
	for i in cnt:
		count += cnt[i] ** 2
	return count
lst = input()
print(solve(lst))


s = input()
alpha = [0 for i in range(100)]
for c in s:
	alpha[ord(c) - ord('1')] += 1
ans = 0
for k in alpha:
	ans += k ** 2
print(ans)


a = list(input())
k = set(a)
s = 0
for i in k:
	s = s + a.count(i) * a.count(i)
print(s)


s = input()
count = {}
total = 0
for i in s:
	if ord(i) in count:
		count[ord(i)] += 1
		total += count[ord(i)] * 2 - 1
	else:
		total += 1
		count[ord(i)] = 1
print(total)


string = input()
count = {}
for i in string:
	if i in count:
		count[i] += 1
	else:
		count[i] = 1
answer = 0
for i in count:
	answer += count[i] ** 2
print(answer)


s = input()
d = {}
for (i, x) in enumerate(s):
	if d.get(x) == None:
		d[x] = 0
	d[x] += 1
res = 0
for (i, x) in enumerate(d):
	res += d[x] ** 2
print(res)


import collections
S = input().strip()
bucket_sort = collections.defaultdict(int)
for c in S:
	bucket_sort[c] += 1
total = 0
for c in bucket_sort.keys():
	total += bucket_sort[c] ** 2
print(total)


from collections import defaultdict
s = input()
dic = defaultdict(int)
for i in s:
	dic[i] += 1
num = 0
for v in dic.values():
	num += v * v
print(num)


s = input()
b = 0
a = {}
for i in s:
	if i not in a:
		a[i] = 1
	else:
		a[i] += 1
for i in a.values():
	b += i ** 2
print(b)


def main(chars):
	counts = dict()
	for char in chars:
		try:
			counts[char] += 1
		except KeyError:
			counts[char] = 1
	squares = [char_count ** 2 for char_count in counts.values()]
	return sum(squares)
print(main(input()))


s = input()
res = 0
for i in set(s):
	res += s.count(i) ** 2
print(res)


m = input()
s = 0
d = {}
for i in m:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
for value in d.values():
	s += value ** 2
print(s)


n = input()
x = [i for i in n]
x = set(x)
m = {}
a = 0
for i in n:
	m[i] = m.get(i, 0) + 1
for i in x:
	a += m[i] ** 2
print(a)


s = input()
m = 0
cnt = {}
for i in s:
	cnt[i] = cnt.get(i, 0) + 1
ls = list(cnt.items())
for each in ls:
	m += int(each[1]) ** 2
print(m)


a = list(input())
print(sum((a.count(i) ** 2 for i in set(a))))


my_string = input()
my_dict = {}
for el in my_string:
	my_dict[el] = my_dict.get(el, 0) + 1
answer = 0
for n in my_dict.values():
	answer += n * n
print(answer)


from collections import Counter
import math
my_string = str(input())
counter = Counter(my_string)
sum = 0
for line in counter:
	sum = sum + math.pow(int(counter[line]), 2)
print(int(sum))


import sys
from collections import Counter
for line in sys.stdin:
	line = line.strip()
	counter = Counter(line)
	count = 0
	for c in counter:
		count += counter[c] * counter[c]
	print(count)


s = input()
f = {}
for j in s:
	if j not in f:
		f[j] = 1
	else:
		f[j] += 1
ans = 0
for k in f.keys():
	ans += f[k]
	ans += (f[k] - 1) * f[k]
print(ans)


def help(n):
	return n * n

def fun(s):
	d = {}
	for i in range(len(s)):
		if s[i] in d:
			d[s[i]].append(i)
		else:
			d[s[i]] = [i]
	c = 0
	for i in d:
		c += help(len(d[i]))
	return c
s = input()
print(fun(s))


s = input()
d = {}
sum = 0
for c in s:
	if c in d:
		d[c] = d[c] + 1
	else:
		d[c] = 1
for k in d:
	sum = sum + d[k] * d[k]
print(sum)


a = list(input())
b = []
for i in set(a):
	b.append(a.count(i))
print(sum((i ** 2 for i in b)))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
s = input()
n = len(s)
d = dict()
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
r = 0
for i in d:
	r += d[i] * d[i]
print(r)


s = input()
m = 0
d = {}
for i in s:
	d[i] = d.get(i, 0) + 1
ls = list(d.items())
for each in ls:
	if each[1] > 1:
		m += each[1] ** 2
	else:
		m += 1
print(m)


a = input()
fq = []
sol = 0
for i in range(1, 200):
	fq.append(0)
for i in a:
	fq[ord(i)] += 1
for i in a:
	if fq[ord(i)] != 0:
		sol += fq[ord(i)] - 1
sol += len(a)
print(sol)


s = input()
d = {}
sum = 0
for i in s:
	d[i] = d.get(i, 0) + 1
for each in d.values():
	sum += each ** 2
print(sum)


s = input()
count = 0
ls = {}
for i in s:
	ls[i] = ls.get(i, 0) + 1
f = ls.values()
for j in f:
	count += j * j
print(count)


lis = input()
count = dict()
for i in lis:
	count[i] = count.get(i, 0) + 1
sum = 0
for i in count.values():
	sum = sum + i * i
print(sum)


import sys
import math
alpha = 'abcdefghijklmnopqrstuvwxyz0123456789'

def main():
	s = list(sys.stdin.readline().strip())
	res = 0
	for c in alpha:
		res += s.count(c) ** 2
	print(res)
main()


a = [i for i in input()]
a.sort()
count = len(a)
b = {}
for (i, k) in enumerate(a):
	b[str(k)] = []
for (i, k) in enumerate(a):
	b[str(k)].append(i)
for i in b:
	count += len(b[i]) * (len(b[i]) - 1)
print(count)


a = list(input())
s = 0
b = []
for i in a:
	if i not in b:
		b.append(i)
		l = a.count(i)
		s = s + l ** 2
print(s)


n = input()
x = {}
y = 0
for i in n:
	x[i] = x.get(i, 0) + 1
for i in x:
	y += x[i] * x[i]
print(y)


from collections import Counter
print(sum(map(lambda x: x ** 2, Counter(input()).values())))


a = list(input())
s = 0
b = []
for i in set(a):
	l = a.count(i)
	s = s + l ** 2
print(s)


s = input()
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
res = 0
for i in d:
	res += d[i] * d[i]
print(res)


def symbol_pair(str):
	occurences = dict()
	for i in str:
		if i not in occurences:
			occurences[i] = 1
		else:
			occurences[i] += 1
	total = 0
	for key in occurences.keys():
		total += occurences[key] ** 2
	return total
print(symbol_pair(input()))


s = input()
print(sum([s.count(x) ** 2 for x in set(s)]))


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	s = input()
	C = Counter(s)
	ans = 0
	for j in C.values():
		ans += j * j
	print(ans)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


import math, collections

def nCr(n, r):
	return n * (n - 1)

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
s = str(input())
dictt = collections.Counter(s)
ans = len(s)
for i in dictt.values():
	if i > 1:
		ans += nCr(i, 2)
print(int(ans))


s = input()
d = {}
count = 0
for i in s:
	d[i] = d.get(i, 0) + 1
l = list(d.values())
for i in l:
	count += i ** 2
print(count)


s = ','.join(input().split())
sj = list(set(s))
cnt = 0
for i in sj:
	cnt += s.count(i) ** 2
print(cnt)


s = input()
ans = 0
p = list(set(s))
for j in p:
	ans += s.count(j) ** 2
print(ans)


from collections import Counter
s = list(input())
t = Counter(s)
su = 0
for i in t:
	su = su + t[i] * t[i]
print(su)


s = input()
x = list(set(s))
ans = 0
for i in range(0, len(x)):
	ans += s.count(x[i]) ** 2
print(ans)


word = input()
counts = [word.count(c) for c in set(word)]
print(sum(map(lambda val: val ** 2, counts)))


def f(x=input()):
	d = dict()
	for i in x:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	return sum([j * j for (_, j) in d.items()])
print(f())


from collections import Counter
s = input()
c = Counter(s)
res = 0
for (_, v) in c.items():
	res += v ** 2
print(int(res))


string = input()
arr = [0] * 128
for r in range(len(string)):
	arr[ord(string[r])] += 1
total = 0
myset = set(string)
for val in myset:
	total = total + arr[ord(val)] ** 2
print(total)


a = str(input())
aq = 0
aw = 0
ae = 0
ar = 0
at = 0
ay = 0
au = 0
ai = 0
ao = 0
ap = 0
aa = 0
ass = 0
ad = 0
af = 0
ag = 0
ah = 0
aj = 0
ak = 0
al = 0
az = 0
ax = 0
ac = 0
av = 0
ab = 0
an = 0
am = 0
a1 = 0
a2 = 0
a3 = 0
a4 = 0
a5 = 0
a6 = 0
a7 = 0
a8 = 0
a9 = 0
a0 = 0
for i in range(len(a)):
	if a[i] == 'q':
		aq += 1
	if a[i] == 'w':
		aw += 1
	if a[i] == 'e':
		ae += 1
	if a[i] == 'r':
		ar += 1
	if a[i] == 't':
		at += 1
	if a[i] == 'y':
		ay += 1
	if a[i] == 'u':
		au += 1
	if a[i] == 'i':
		ai += 1
	if a[i] == 'o':
		ao += 1
	if a[i] == 'p':
		ap += 1
	if a[i] == 'a':
		aa += 1
	if a[i] == 's':
		ass += 1
	if a[i] == 'd':
		ad += 1
	if a[i] == 'f':
		af += 1
	if a[i] == 'g':
		ag += 1
	if a[i] == 'h':
		ah += 1
	if a[i] == 'j':
		aj += 1
	if a[i] == 'k':
		ak += 1
	if a[i] == 'l':
		al += 1
	if a[i] == 'z':
		az += 1
	if a[i] == 'x':
		ax += 1
	if a[i] == 'c':
		ac += 1
	if a[i] == 'v':
		av += 1
	if a[i] == 'b':
		ab += 1
	if a[i] == 'n':
		an += 1
	if a[i] == 'm':
		am += 1
	if a[i] == '1':
		a1 += 1
	if a[i] == '2':
		a2 += 1
	if a[i] == '3':
		a3 += 1
	if a[i] == '4':
		a4 += 1
	if a[i] == '5':
		a5 += 1
	if a[i] == '6':
		a6 += 1
	if a[i] == '7':
		a7 += 1
	if a[i] == '8':
		a8 += 1
	if a[i] == '9':
		a9 += 1
	if a[i] == '0':
		a0 += 1
b = int(aq ** 2) + int(aw ** 2) + int(ae ** 2) + int(ar ** 2) + int(at ** 2) + int(ay ** 2)
b = b + int(ap ** 2) + int(aa ** 2) + int(ass ** 2) + int(ad ** 2) + int(af ** 2) + int(ag ** 2)
b = b + int(al ** 2) + int(az ** 2) + int(ak ** 2) + int(ao ** 2) + int(ax ** 2) + int(ac ** 2)
b = b + int(an ** 2) + int(am ** 2) + int(a1 ** 2) + int(a2 ** 2) + int(a3 ** 2) + int(a4 ** 2)
b = b + int(a7 ** 2) + int(a8 ** 2) + int(a9 ** 2) + int(a0 ** 2) + int(au ** 2) + int(ai ** 2)
b = b + int(ah ** 2) + int(aj ** 2) + int(av ** 2) + int(ab ** 2) + int(a5 ** 2) + int(a6 ** 2)
print(b)


x = input()
ls1 = []
for i in x:
	ls1.append(i)
d = {}
for i in x:
	d[i] = d.get(i, 0) + 1
sum = 0
ls = list(d.values())
for i in ls:
	sum += i ** 2
print(sum)


S = list(input())
S.sort()
total = 0
while len(S) > 0:
	i = S[0]
	t = S.count(i)
	total += t ** 2
	for j in range(t):
		del S[0]
print(total)


s = input()
distinct_element = []
for i in range(37):
	distinct_element.append(0)
for i in range(len(s)):
	if ord(s[i]) >= 48 and ord(s[i]) <= 57:
		distinct_element[ord(s[i]) - 48] += 1
	else:
		distinct_element[ord(s[i]) - 87] += 1
cnt = 0
for i in range(37):
	cnt += distinct_element[i] ** 2
print(cnt)


import sys
import os.path
import math
import heapq
from sys import stdin, stdout
from collections import *
from math import gcd, ceil, floor
mod = int(1000000000.0 + 7)
if os.path.exists('Updated prg/Input3d.txt'):
	sys.stdout = open('Updated prg/Output3d.txt', 'w')
	sys.stdin = open('Updated prg/Input3d.txt', 'r')

def sinp():
	return input()

def ninp():
	return int(sinp())

def mapinp():
	return map(int, sinp().split())

def linp():
	return list(mapinp())

def sl():
	return list(sinp())

def prnt(a):
	print(a)
s1 = sinp()
l1 = Counter(s1)
c = 0
for i in l1:
	c = c + l1[i] * l1[i]
prnt(c)


s = list(input())
ans = len(s)
dic = {}
for item in s:
	if item not in dic:
		dic[item] = 1
	else:
		dic[item] += 1
for item in dic.keys():
	ans += dic[item] * (dic[item] - 1)
print(ans)


slovo = input()
serazeno = sorted(slovo)
a = serazeno[0]
vysledek = 0
cislo = 1
kontrola = 0
for i in range(len(serazeno) - 1):
	if serazeno[i] == serazeno[i + 1]:
		cislo += 1
	else:
		vysledek += cislo ** 2
		kontrola += cislo
		cislo = 1
	a = i
if kontrola != len(slovo):
	vysledek += cislo ** 2
print(vysledek)


s = input()
from collections import Counter
cnts = Counter(s)
cnt = 0
for i in s:
	cnt += cnts[i]
print(cnt)


from collections import Counter as C
print(sum((v ** 2 for v in C(input().strip()).values())))


s = input()
ls1 = []
ls2 = []
a = {}
t = 0
for i in range(len(s)):
	ls1.append(s[i])
for i in range(len(s)):
	a[ls1[i]] = a.get(ls1[i], 0) + 1
ls1 = list(set(ls1))
for i in range(len(ls1)):
	ls2.append(a[ls1[i]])
for i in ls2:
	i = int(i)
	if i != 1:
		t += i ** 2
	else:
		t += 1
print(t)


ls = list(input())
count = 0
a = set(ls)
for i in a:
	count += ls.count(i) ** 2
print(count)


s = input()
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = 0
for i in d.values():
	ans += i * (i - 1) // 2
print(2 * ans + len(s))


ls = list(input())
d = {}
for i in ls:
	d[i] = d.get(i, 0) + 1
count = 0
for v in d.values():
	count += v ** 2
print(count)


s = input()
l = {}
for i in s:
	l[i] = l.get(i, 0) + 1
ls = list(l.values())
sum = 0
for i in ls:
	sum += i * i
print(sum)


s = input()
s = [s.count(x) for x in set(s)]
print(sum(map(lambda x: x ** 2, s)))


p = list(input())
sum = 0
for i in set(p):
	sum = sum + p.count(i) ** 2
print(sum)


b = {}
for c in input():
	if c in b:
		b[c] += 1
	else:
		b[c] = 1
ans = 0
for c in b:
	ans += b[c] ** 2
print(ans)


s = input()
a = set(s)
ans = 0
for i in a:
	ans += s.count(i) ** 2
print(ans)


cnt = {}
for _ in list(input()):
	cnt[_] = cnt.get(_, 0) + 1
ans = 0
for _ in cnt.values():
	ans += _ + _ * (_ - 1)
print(ans)


s = input()
print(sum((s.count(k) ** 2 for k in set(s))))


a = input()
c = 0
d = {}
for i in a:
	if i in d:
		d[i] = d[i] + 1
	else:
		d[i] = 1
for i in d:
	c = c + d[i] * d[i]
print(c)


import sys
from collections import Counter
s = sys.stdin.readline().rstrip()
c = Counter(s)
print(sum([i ** 2 for i in c.values()]))


from collections import defaultdict
d = defaultdict(int)
s = input()
for c in s:
	d[c] += 1
l = list(d.values())
print(sum([i ** 2 for i in l]))


import random
import math
a = input()
l = len(a)
li = []
for i in range(0, l):
	li.append(a[i])
li.append('+')
li.sort()
li.reverse()
com = 1
list = []
for i in range(0, l):
	if li[i] == li[i + 1]:
		com += 1
		if i == l:
			list.append(com)
	else:
		list.append(com)
		com = 1
total = 0
for i in range(0, len(list)):
	if list[i] == 1:
		total = total + 1
	else:
		total = total + list[i] * list[i]
print(total)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	c = Counter(input())
	l = list(c.values())
	ans = 0
	for item in l:
		ans += item * item
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
s = input()
l = defaultdict(int)
for i in range(len(s)):
	l[s[i]] += 1
ans = 0
for x in l:
	ans = ans + l[x] * l[x]
print(ans)


s = str(input())
l = list(s)
l.sort()
counter1 = 0
counter2 = 0
ans = 0
tmp = l[0]
while counter1 < len(l):
	tmp = l[counter1]
	counter2 = counter1
	while counter2 < len(l) and l[counter2] == tmp:
		counter2 += 1
	x = (counter2 - counter1) ** 2
	ans += x
	counter1 = counter2
print(ans)


slad = input()
dlad = {}
suma = 0
for clac in slad:
	if clac in dlad:
		dlad[clac] = dlad[clac] + 1
	else:
		dlad[clac] = 1
for klak in dlad:
	suma = suma + dlad[klak] * dlad[klak]
print(suma)


s = str(input())
k = 1
arr = []
res = 0
test = 'qwertyuiopasdfghjklzxcvbnm0123456789'
for i in range(len(s)):
	arr.append(s[i])
arr.sort()
fl = True
i = 0
while i < len(arr) - 1 and fl:
	if arr[i + 1] == arr[i]:
		k += 1
	else:
		res = res + k * k
		k = 1
	if i == len(arr) - 2:
		fl = False
	if fl == False:
		res = res + k * k
	i += 1
if i == 0:
	res = 1
print(res)


x = input()
mp = {}
d = {}
for i in range(0, len(x)):
	if x[i] not in mp:
		mp[x[i]] = 1
	else:
		mp[x[i]] = mp[x[i]] + 1
sum = 0
for i in range(0, len(x)):
	if x[i] not in d:
		d[x[i]] = 1
		sum = sum + mp[x[i]] * mp[x[i]]
print(sum)


string = input()
ans = 0
for iter in set(string):
	ans += string.count(iter) ** 2
print(ans)


from collections import Counter
s = input()
c = Counter(s)
cnt = 0
for x in c:
	cnt += c[x] * c[x]
print(cnt)


s = input()
a = [0] * 100001
for i in s:
	a[ord(i)] += 1
ans = 0
for i in a:
	ans += i ** 2
print(ans)


def ad(d, c):
	if c in d:
		d[c] += 1
	else:
		d[c] = 1
d = dict()
s = input()
for c in s:
	ad(d, c)
n = 0
for c in list(d.values()):
	n += c * c
print(n)


from collections import Counter
print(sum([value ** 2 for value in Counter(input()).values()]))


from collections import Counter
x = Counter(input())
counter = 0
for i in x:
	counter += x[i] ** 2
print(counter)


s = input()
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
print(sum(map(lambda x: x * x, d.values())))


r = range
s = input()
M = [0 for x in r(500)]
for _ in r(len(s)):
	M[ord(s[_])] += 1
t = 0
for _ in r(500):
	t += M[_] * M[_]
print(t)


from collections import defaultdict
p = defaultdict(int)
for i in input():
	p[i] += 1
print(sum((x * x for x in p.values())))


s = input()
dic = {}
b = len(s)
counter = 0
for i in range(b):
	t = s[i]
	if t in dic:
		dic[t] += 1
	else:
		dic[t] = 1
for i in dic:
	counter = counter + int(dic[i]) ** 2
print(counter)


n = input()
l = len(n)
dic = {}
for i in n:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
ans = 0
for i in dic.values():
	ans += max(i - 1, 0) * i
print(ans + l)


s = list(input())
sum = 0
for i in set(s):
	sum = sum + s.count(i) ** 2
print(sum)


S = str(input())
M = set(S)
c = 0
for m in M:
	c += S.count(m) ** 2
print(c)


m = input()
n = {}
s = 0
for each in m:
	n[each] = n.get(each, 0) + 1
for i in n:
	s += n[i] * n[i]
print(s)


x = input()
dictx = {}
for i in x:
	if i in dictx:
		dictx[i] += 1
	else:
		dictx[i] = 1
total = 0
for i in dictx:
	total += dictx[i] ** 2
print(total)


import sys
import os
from io import IOBase, BytesIO
import math
mod = 10 ** 9 + 7
pie = 3.1415926536

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def read2DIntArray(row, col):
	arr = []
	for i in range(0, row):
		temp = list(map(int, sin().split()))
		arr.append(temp)
	return arr

def read2DCharArray(row, col):
	arr = []
	for i in range(0, row):
		temp = str(sin())
		arr.append(temp)
	return arr

def smallestNumber(n):
	lst = list(str(n))
	lst.sort()
	tmp = ''
	for (i, n) in enumerate(lst):
		if n != '0':
			tmp = lst.pop(i)
			break
	return str(tmp) + ''.join(lst)

def main():
	s = sin()
	dic = dict.fromkeys(list(s), 0)
	for c in s:
		dic[c] += 1
	ans = 0
	for num in dic.values():
		ans += num ** 2
	print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


word = input()
ans = 0
num = {}
for i in word:
	num[i] = num.get(i, 0) + 1
for j in num.values():
	ans += j ** 2
print(ans)


a = input().strip()
d = {}
for i in range(len(a)):
	d[a[i]] = d.get(a[i], 0) + 1
c = 0
for i in d:
	c += d[i] * d[i]
print(c)


s = input()
counted = []
count = 0
for i in s:
	if i not in counted:
		counted.append(i)
		count += list(s).count(i) ** 2
print(count)


s = input()
alphabet_and_digit = []
for i in range(0, 11):
	alphabet_and_digit.append(str(i))
for i in range(11, 37):
	alphabet_and_digit.append(chr(ord('a') + i - 11))
distinct_element = []
for i in range(37):
	distinct_element.append(0)
for i in range(len(s)):
	distinct_element[alphabet_and_digit.index(s[i])] += 1
cnt = 0
for i in range(37):
	cnt += distinct_element[i] ** 2
print(cnt)


S = input()
cnt = 0
ls = []
for each in set(S):
	ls.append(S.count(each))
for i in ls:
	cnt += pow(i, 2)
print(cnt)


w = input()
p = []
for i in w:
	if i not in p:
		p.append(i)
s = 0
for i in p:
	s += w.count(i) * w.count(i)
print(s)


s = input()
t = {}
p = 0
z = 0
for i in s:
	if i in t:
		t[i] += 1
	else:
		t[i] = 1
for k in t:
	if t[k] >= 1:
		p = int(t[k]) ** 2
		z += p
if t[i] == 1:
	print(len(s))
else:
	print(z)


s = input()
from collections import Counter
tot = 0
c = Counter(s)
for i in c:
	tot += c[i] ** 2
print(tot)


from collections import Counter
k = 0
s = input()
d = Counter(s)
for key in d.keys():
	k += d[key] ** 2
print(k)


S = input()
freqs = dict()
for letter in S:
	if letter in freqs:
		freqs[letter] += 1
	else:
		freqs[letter] = 1
doubles = 0
for f in freqs.values():
	doubles += f ** 2
print(doubles)


s = input()
count = 0
d = {}
for i in s:
	d[i] = d.get(i, 0) + 1
for v in d.values():
	count += v ** 2
print(count)