There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.

For example, if there are $6$ students: "olivia", "jacob", "tanya", "jack", "oliver" and "jessica", then:  splitting into two classrooms ("jack", "jacob", "jessica", "tanya") and ("olivia", "oliver") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms ("jack", "tanya", "olivia") and ("jessica", "oliver", "jacob") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). 

You are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?

Note that it is valid to place all of the students in one of the classrooms, leaving the other one empty.


-----Input-----

The first line contains a single integer $n$ ($1\leq n \leq 100$) — the number of students.

After this $n$ lines follow.

The $i$-th line contains the name of the $i$-th student.

It is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.


-----Output-----

The output must consist of a single integer $x$ — the minimum possible number of chatty pairs.


-----Examples-----
Input
4
jorge
jose
oscar
jerry

Output
1

Input
7
kambei
gorobei
shichiroji
kyuzo
heihachi
katsushiro
kikuchiyo

Output
2

Input
5
mike
mike
mike
mike
mike

Output
4



-----Note-----

In the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.

In the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.

In the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.

Source: codeforces | Difficulty: EASY
Tags: Combinatorics

Greedy algorithms


Solutions:
n = int(input())
d = {}
for _ in range(n):
	name = input()
	if name[0] in d:
		d[name[0]] += 1
	else:
		d[name[0]] = 1
res = 0
for i in d:
	a = d[i] // 2
	b = d[i] - a
	res += a * (a - 1) / 2 + b * (b - 1) / 2
print(int(res))


def minimum_chatty_pairs(alumns):
	occurs = {}
	chatties = 0
	for name in alumns:
		if name[0] not in occurs:
			occurs[name[0]] = 0
		occurs[name[0]] += 1
	for key in occurs:
		occur = occurs[key]
		side_a = occur // 2
		side_b = (occur + 1) // 2
		chatties += side_a * (side_a - 1) // 2
		chatties += side_b * (side_b - 1) // 2
	return chatties
n = int(input())
alumns = []
for i in range(n):
	name = input()
	alumns.append(name)
print(minimum_chatty_pairs(alumns))


n = int(input())
arr = []
for i in range(n):
	arr.append(list(input())[0])
d = {}
for i in range(len(arr)):
	if arr[i] not in list(d.keys()):
		d[arr[i]] = 1
	else:
		d[arr[i]] += 1
l = list(d.keys())
result = 0
for i in range(len(l)):
	if d[l[i]] > 1:
		if d[l[i]] % 2 == 0:
			result += d[l[i]] * d[l[i]] / 4 - d[l[i]] / 2
		elif d[l[i]] > 3:
			result += (d[l[i]] - 1) * (d[l[i]] - 1) / 4
		else:
			result += 1
print(int(result))


from collections import *
n = int(input())
l = [input()[:1] for i in range(n)]
ans = 0
d = Counter(l)
for i in d:
	x = 0
	y = 0
	if d[i] % 2 == 1:
		x = d[i] // 2
		y = x + 1
		ans += x * (x - 1) // 2
		ans += y * (y - 1) // 2
	else:
		x = d[i] // 2
		ans += x * (x - 1) // 2
		ans += x * (x - 1) // 2
print(ans)


n = int(input(''))
t = []
for i in range(n):
	t.append(input(''))
found = 0
count = 0

def frequency(t, a):
	count = 0
	for k in t:
		if a == k[0]:
			count += 1
	return count
sum = 0
for z in range(len(t)):
	found = 0
	r = t[z]
	for h in range(z):
		q = t[h]
		if q[0] == r[0]:
			found = 1
	if found == 0:
		p = frequency(t, r[0])
		if p > 2:
			c = p // 2
			d = c + p % 2
			sum = sum + int(c * (c - 1) / 2 + d * (d - 1) / 2)
print(sum)


n = int(input())
dictionary = {}
symbols = []
for _ in range(n):
	sym = input()[0]
	symbols.append(sym)
	dictionary[sym] = 0
first_class = []
second_class = []
for sym in symbols:
	if dictionary[sym] == 0:
		first_class.append(sym)
		dictionary[sym] = 1
	else:
		second_class.append(sym)
		dictionary[sym] = 0
x = 0
symbols = set(symbols)
for sym in symbols:
	quantity = first_class.count(sym)
	x += (quantity - 1) * (quantity / 2)
	quantity = second_class.count(sym)
	x += (quantity - 1) * (quantity / 2)
print(int(x))


def chatty(x):
	a = x // 2
	b = x - a
	h = a * (a - 1) // 2
	h += b * (b - 1) // 2
	return h
g = int(input())
db = [0] * 26
for i in range(g):
	nev = input()
	db[ord(nev[0]) - ord('a')] += 1
sum = 0
for i in db:
	sum += chatty(i)
print(sum)


d = {}
n = int(input())
t_pairs = 0
for i in range(n):
	t = input()
	if t[0] in d:
		d[t[0]] = d[t[0]] + 1
	else:
		d[t[0]] = 1
for i in d:
	if d[i] % 2 == 1:
		r = d[i] // 2
		t1 = r * (r - 1) // 2
		t2 = (r + 1) * r // 2
		pairs = t1 + t2
	else:
		r = d[i] // 2
		pairs = r * (r - 1)
	t_pairs = t_pairs + pairs
print(t_pairs)


n = int(input())
a = [input() for i in range(n)]
d = dict()
for s in a:
	d.setdefault(s[0], 0)
	d[s[0]] += 1
count = 0
for i in d.values():
	x = i // 2
	count += x * (x - 1) // 2 + (i - x) * (i - x - 1) // 2
print(count)


from collections import defaultdict
import math
f = lambda n: math.factorial(n) // math.factorial(2) // math.factorial(n - 2)
d = defaultdict(int)
for i in range(int(input())):
	s = input()
	d[s[0]] += 1
ans = 0
for (value, key) in d.items():
	if key <= 2:
		continue
	elif key == 3:
		ans += 1
	else:
		a = key // 2
		b = key - a
		ans += f(a)
		ans += f(b)
print(ans)


import math
n = int(input())
a = [0] * 26
for i in range(n):
	s = list(input())
	a[ord(s[0]) - 97] += 1
ans = 0
for i in range(26):
	k1 = 0
	k2 = 0
	k1 = math.ceil(a[i] / 2)
	k2 = math.floor(a[i] / 2)
	ans += k1 * (k1 - 1) // 2
	ans += k2 * (k2 - 1) // 2
print(ans)


n = int(input())
ar = [0] * 26
k = 0
for i in range(n):
	s = input()
	ar[ord(s[0]) - 97] += 1
for i in range(26):
	if ar[i] > 2:
		if ar[i] % 2 == 0:
			p = ar[i] // 2
			t = p * (p - 1) // 2
			k = k + t * 2
		else:
			p = ar[i] // 2
			t = p * (p - 1) // 2
			r = p * (p + 1) // 2
			k = k + t + r
print(k)


def chatty(n_students):
	w = n_students // 2
	return w * (w - 1) if n_students % 2 == 0 else w * w

def main():
	n = int(input())
	class_dict = {}
	for i in range(n):
		name = input()[0]
		class_dict[name] = class_dict.get(name, 0) + 1
	result = sum((chatty(n_students) for n_students in class_dict.values()))
	print(result)
main()


n = int(input())
s = []
for i in range(n):
	r = str(input())
	s.append(r[0])
r = set(s)
p = list(r)
l = []
c = 0
for i in range(len(p)):
	l.append(s.count(p[i]))
for i in range(len(l)):
	if l[i] % 2 == 0:
		o = int(l[i] / 2)
		for i in range(1, o):
			r = o - i
			c += 2 * r
	else:
		o = int(l[i] / 2)
		p = o + 1
		for i in range(1, o):
			r = o - i
			c += r
		for i in range(1, p):
			m = p - i
			c += m
print(c)


n = int(input())
s = [input() for i in range(n)]
ans = 0
for c_i in range(26):
	c = chr(ord('a') + c_i)
	cnt = sum((1 for name in s if name.startswith(c)))
	a = cnt // 2
	b = cnt - a
	ans += a * (a - 1) // 2
	ans += b * (b - 1) // 2
print(ans)


def read_task():
	n = int(input())
	task = []
	for i in range(n):
		task.append(input()[:1])
	return task

def resolve(task):
	count = {}
	for sym in task:
		count[sym] = count.get(sym, 0) + 1
	pairs = 0
	for sym in count:
		c = count[sym]
		c1 = c // 2
		c2 = c - c1
		pairs += c1 * (c1 - 1) // 2
		pairs += c2 * (c2 - 1) // 2
	return pairs

def print_solution(solution):
	print(solution)

def main():
	task = read_task()
	solution = resolve(task)
	print_solution(solution)
main()


n = int(input())
s = []
for i in range(n):
	q = input()
	s.append(q[0])
letters = set(s)
x = 0
for i in letters:
	if s.count(i) <= 2:
		continue
	else:
		c = s.count(i)
		h1 = c // 2
		h2 = c - h1
		x += h1 * (h1 - 1) // 2 + h2 * (h2 - 1) // 2
print(x)


import itertools
import collections
import heapq
import bisect
import math
import sys
import operator
nst = int(input())
s = []
cc = [0] * 128
x = 0
for i in range(0, nst):
	cc[ord(input()[0])] += 1
for i in range(1, 128):
	if cc[i] == 3:
		x += 1
	elif cc[i] > 3:
		class1 = max(0, cc[i] // 2)
		class2 = max(0, (cc[i] + 1) // 2)
		t = math.factorial(class1)
		b = 2 * math.factorial(class1 - 2)
		x += math.factorial(class1) // (2 * math.factorial(class1 - 2)) + math.factorial(class2) // (2 * math.factorial(class2 - 2))
print(x)


n = int(input())
lets = 'qwertyuiopasdfghjklzxcvbnm'
names = [lets.find(input()[0]) for i in range(n)]
nums = [names.count(i) for i in range(26)]
for i in range(26):
	temp = nums[i] % 2
	nums[i] = nums[i] // 2
	nums[i] = nums[i] * (2 * nums[i] - 2 + temp * 2) // 2
print(sum(nums))


import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
first_letter = defaultdict(int)
nb_names = RI()
pairs = 0
for _ in range(nb_names):
	first_letter[RW()[0]] += 1
for letter in first_letter:
	curr = first_letter[letter]
	pair = curr // 2
	nons = curr - pair
	pairs += pair * (pair - 1) // 2
	pairs += nons * (nons - 1) // 2
print(pairs)


def main():
	n = int(input())
	group1 = {}
	group2 = {}
	for i in range(n):
		name = input()
		first = name[0]
		if first in group1.keys():
			if first in group2.keys():
				if group2[first] <= group1[first]:
					group2[first] += 1
				else:
					group1[first] += 1
			else:
				group2[first] = 1
		else:
			group1[first] = 1
	pairs = 0
	for i in group1.keys():
		pairs += group1[i] * (group1[i] - 1) // 2
	for i in group2.keys():
		pairs += group2[i] * (group2[i] - 1) // 2
	print(pairs)
main()


from collections import Counter
n = int(input())

def f(x):

	def g(x):
		return x * (x - 1) // 2
	h = x // 2
	h2 = x - h
	return g(h) + g(h2)
cnt = Counter()
for _ in range(n):
	name = input()
	cnt[name[0]] += 1
res = 0
for v in cnt.values():
	res += f(v)
print(res)


a = [0] * 128
c = 0
for _ in range(int(input())):
	s = input()
	i = ord(s[0])
	a[i] += 1
for i in range(97, 123):
	if a[i] > 2:
		n = int(a[i] / 2)
		m = a[i] - n
		c += int((n - 1) * n / 2)
		c += int((m - 1) * m / 2)
print(c)


n = int(input())

def permutation(n):
	a = (n - 1) * n // 2
	return a
a = [input() for i in range(n)]
b = [a[i][0] for i in range(n)]
c = list(set(b))
d = [b.count(c[i]) for i in range(len(c))]
m = 0
for i in range(len(d)):
	x = permutation(d[i] // 2)
	y = permutation(d[i] - d[i] // 2)
	m += x + y
print(m)


def factorial(n, k):
	if n == 1 or n == 0 or n == k:
		return 1
	return factorial(n - 1, k) * n
n = int(input())
dic = {}
resp = 0
for e in range(n):
	nome = input()
	if nome[0] not in dic:
		dic[nome[0]] = 1
	else:
		dic[nome[0]] += 1
for e in dic:
	aux = dic[e] // 2
	if aux > 1:
		resp += factorial(aux, aux - 2) // 2
	if dic[e] % 2 == 1:
		aux += 1
		resp += factorial(aux, aux - 2) // 2
	else:
		resp += factorial(aux, aux - 2) // 2
print(resp)


n = int(input())
l = []
for i in range(n):
	l.append(input())
d = dict()
for i in range(n):
	x = l[i][0]
	if x not in d:
		d[x] = 1
	else:
		d[x] += 1
c = 0
for i in d:
	x = d[i] // 2
	y = d[i] - x
	c += x * (x - 1) // 2
	c += y * (y - 1) // 2
print(c)


from itertools import accumulate
n = input()
a = []
for _ in range(int(n)):
	a.append(input()[0])
r = 0
for c in 'abcdefghijklmnopqrstuvwxyz':
	co = a.count(c)
	if co == 3:
		r += 1
	elif co == 4:
		r += 2
	elif co > 4:
		x1 = co // 2
		x2 = co % 2 + co // 2
		r += sum(list(range(x1)) + list(range(x2)))
print(r)


aa = 0
ada = []
for i in range(aa):
	i = input()
	ar.append(i)

def common_common(arr):
	commonstring = ''
	if len(arr) > 1 and len(arr[0]) > 0:
		for i in range(len(arr[0])):
			for j in range(len(arr[0]) - i + 1):
				if j > len(commonstring) and is_commonstring(arr[0][i:i + j], arr):
					commonstring = arr[0][i:i + j]
	return commonstring

def is_commonstring(stringg, arr):
	if len(arr) < 1 and len(stringg) < 1:
		return False
	for i in range(len(arr)):
		if stringg not in arr[i]:
			return False
	return True
from collections import Counter
import math
a = int(input())
ar = []
arr = []
for i in range(a):
	i = input()
	ar.append(i)
for i in ar:
	i = ord(str(i[0]))
	arr.append(i)
c = Counter(arr)
d = Counter(c).values()
summ = 0
for i in d:
	if i == 1:
		i = 0
	if i == 2:
		i = 0
	if i == 3:
		summ = summ + 1
	elif i > 3:
		if i % 2 == 0:
			t = i // 2
			t = math.factorial(t) // (2 * math.factorial(t - 2)) * 2
			summ = summ + t
		else:
			t = (i - 1) // 2
			tt = math.factorial(t) // (2 * math.factorial(t - 2))
			t2 = t + 1
			t2 = math.factorial(t2) // (2 * math.factorial(t2 - 2))
			t3 = tt + t2
			summ = summ + t3
print(summ)


def c2(x):
	return x * (x - 1) / 2
n = int(input())
d = {}
for i in range(n):
	temp = input()
	temp = temp[0]
	if temp in d:
		d[temp] = d[temp] + 1
	else:
		d[temp] = 1
ans = 0
for i in d.values():
	if i % 2 == 0:
		temp1 = i / 2
		temp2 = i / 2
	else:
		temp1 = int(i / 2)
		temp2 = int(i / 2) + 1
	ans = ans + c2(temp1) + c2(temp2)
ans = int(ans)
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
count = [0] * 26
for _ in range(n):
	name = input().rstrip()
	count[ord(name[0]) - 97] += 1
from math import factorial

def nCk(n, k):
	if k > n:
		return 0
	return factorial(n) / (factorial(k) * factorial(n - k))
res = 0
for c in count:
	if c % 2 == 0:
		res += 2 * nCk(c // 2, 2)
	else:
		grpA = nCk(c // 2, 2)
		grpB = nCk(c // 2 + 1, 2)
		res += grpA + grpB
print(int(res))


from collections import Counter
n = int(input())
ss = map(lambda x: input()[0], range(n))
ct = list(Counter(ss).values())
x = 0
for c in ct:
	a = c // 2
	b = c - a
	x += int(a * (a - 1) / 2)
	x += int(b * (b - 1) / 2)
print(x)


n = int(input())
l1 = []
table = []
scores = []
for x in range(n):
	letter = input()[0]
	if letter not in table:
		table.append(letter)
		scores.append(1)
	else:
		scores[table.index(letter)] += 1
ans = 0
for x in scores:
	s = int(x / 2) + x % 2
	s1 = x - s
	if s > 1:
		ans += s * (s - 1) / 2
	if s1 > 1:
		ans += s1 * (s1 - 1) / 2
print(int(ans))


from collections import defaultdict as dd
n = int(input())
cdict = dd(int)
for _ in range(n):
	name = input()
	cdict[name[0]] += 1
x = 0
for i in range(26):
	div = cdict[chr(97 + i)] // 2
	if cdict[chr(97 + i)] % 2 == 0:
		x += (div - 1) * div
	else:
		x += (div - 1) * div // 2 + (div + 1) * div // 2
print(x)


n = int(input())
(s, d) = ([], [])
c = 0
r = set()
for i in range(n):
	e = input()[0]
	if s.count(e) == d.count(e):
		s.append(e)
	else:
		d.append(e)
for i in d:
	if i not in r:
		c += sum(range(d.count(i)))
		r.add(i)
r.clear()
for i in s:
	if i not in r:
		c += sum(range(s.count(i)))
		r.add(i)
print(c)


n = int(input())
names = [0 for i in range(26)]
for i in range(n):
	name = input()
	name = name[:1]
	names[int(ord(name)) - 97] += 1
x = 0
for i in names:
	if i > 1:
		if i % 2 == 0:
			x += i * (i - 2) / 4
		else:
			x += (i + 1) * (i - 1) / 8 + (i - 1) * (i - 3) / 8
print(int(x))


def fat(num):
	if num == 0:
		return 1
	return num * fat(num - 1)

def comb(a, b):
	return fat(a) // (fat(b) * fat(a - b))
n = int(input())
letra = {}
tot = 0
for e in range(n):
	name = input()
	if name[0] not in letra:
		i = name[0]
		letra[i] = 1
	else:
		letra[name[0]] += 1
for j in letra:
	freq1 = int(letra[j]) // 2
	freq2 = int(letra[j]) - freq1
	if freq1 < 1:
		tot += 0
	elif freq1 > 1:
		tot += comb(freq1, 2)
		tot += comb(freq2, 2)
	elif freq1 <= 1 and freq2 > 1:
		tot += comb(freq2, 2)
print(tot)


n = int(input())
arr = [0 for i in range(26)]
for i in range(n):
	p = input()
	arr[ord(p[0]) - 97] += 1
sumi = 0
for i in arr:
	if i == 3:
		sumi += 1
	elif i > 2:
		divided1 = i // 2 * (i // 2 - 1) / 2
		divided2 = (i - i // 2) * (i - i // 2 - 1) / 2
		sumi += divided1 + divided2
print(int(sumi))


import string
n = int(input())
ar = [0] * 26
alp = list(string.ascii_lowercase)
for k in range(n):
	temp = alp.index(input()[0:1])
	ar[temp] += 1
ans = 0
for k in ar:
	if k % 2 == 0:
		a = k / 2
		b = k / 2 - 1
		ans += a * b
	else:
		a = (k + 1) / 2
		b = (k + 1) / 2 - 1
		c = (k - 1) / 2
		d = (k - 1) / 2 - 1
		ans += a * b / 2 + c * d / 2
print(int(ans))


factorial = [1] * 101
for i in range(1, 101):
	factorial[i] = factorial[i - 1] * i

def combination(a, b):
	if b > a:
		return 0
	return factorial[a] / (factorial[b] * factorial[a - b])
numberStudents = int(input())
room1 = dict()
room2 = dict()
for i in range(numberStudents):
	studentName = input()
	initial = studentName[0]
	room1WithMoreOfThisInitial = False
	if initial not in room1.keys():
		room1[initial] = 0
	if initial not in room2.keys():
		room2[initial] = 0
	if room1[initial] > room2[initial]:
		room1WithMoreOfThisInitial = True
	if room1WithMoreOfThisInitial:
		room2[initial] += 1
	else:
		room1[initial] += 1
answer = 0
if len(room1) > len(room2):
	seen1 = []
	for (k, v) in room1.items():
		if k in seen1:
			break
		seen1.append(k)
		if v > 1:
			answer += combination(v, 2)
		if k in room2.keys():
			if room2[k] > 1:
				answer += combination(room2[k], 2)
else:
	seen1 = []
	for (k, v) in room2.items():
		if k in seen1:
			break
		seen1.append(k)
		if v > 1:
			answer += combination(v, 2)
		if k in room1.keys():
			if room1[k] > 1:
				answer += combination(room1[k], 2)
print(int(answer))


n = int(input())
l1 = [0] * 26
for i in range(n):
	s = input()
	l1[ord(s[0]) - 97] += 1
ans = 0
for item in l1:
	x = item // 2
	y = item - x
	ans += x * (x - 1) // 2
	ans += y * (y - 1) // 2
print(ans)


n = int(input())
d = {}
for k in range(n):
	nk = input()[0]
	if nk not in d:
		d[nk] = 0
	d[nk] += 1
res = 0

def pairs(n):
	return n * (n - 1) // 2
for k in d.values():
	res += pairs(k // 2) + pairs(k - k // 2)
print(res)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
n = ri()
ans = 0
d = {}
for _ in range(n):
	x = rl()[0]
	if x not in d:
		d[x] = [0, 0]
	ans += d[x][0]
	d[x][0] += 1
	(d[x][0], d[x][1]) = (d[x][1], d[x][0])
print(ans)


from collections import Counter
n = int(input())
letters = []
for _ in range(n):
	letters.append(input()[0])
l = list(Counter(letters).values())

def som(m):
	return m * (m - 1) / 2
s = 0
for i in l:
	s += som(i // 2) + som(i - i // 2)
print('%d' % s)


n = int(input())
arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
g2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
g1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(n):
	s = input()
	z = ord(s[0]) - 97
	arr[z] += 1
for j in range(26):
	x = arr[j]
	if x % 2 == 0:
		g1[j] = x / 2
		g2[j] = x / 2
	else:
		g1[j] = int(x / 2)
		g2[j] = g1[j] + 1
c = 0

def fac(n):
	ans = n * (n - 1) / 2
	return ans
for k in range(26):
	add1 = fac(g1[k])
	add2 = fac(g2[k])
	c = c + add1 + add2
	c = int(c)
print(c)


n = int(input())
p = []
buf = 1
need = []
x = 0
for q in range(n):
	p.append(input())
p.sort()
for i in range(len(p) - 1):
	if p[i][0] == p[i + 1][0]:
		buf += 1
	else:
		need.append(buf)
		buf = 1
need.append(buf)
for j in range(len(need)):
	if need[j] > 1:
		if need[j] % 2 == 0:
			x += (need[j] // 2 - 1) * (need[j] // 2)
		else:
			x += (need[j] // 2 - 1) * (need[j] // 2) // 2
			x += need[j] // 2 * (need[j] // 2 + 1) // 2
print(x)


n = int(input())
c = {}
for _ in range(n):
	x = input()[0]
	c[x] = c.get(x, 0) + 1
s = 0
for x in c.values():
	y = x // 2
	x -= y
	s += x * (x - 1) + y * (y - 1)
print(s // 2)


from math import ceil
arr = [0] * 26
ans = 0
n = int(input())
for i in range(n):
	arr[ord(input()[:1]) - ord('a')] += 1
for i in arr:
	ans += i // 2 * (i // 2 - 1) // 2 + ceil(i / 2) * (ceil(i / 2) - 1) // 2
print(ans)


n = int(input())
cnt = [0] * 26
for i in range(0, n):
	cnt[int(ord(input()[0]) - ord('a'))] += 1
ans = 0
for i in range(0, 26):
	x = int(cnt[i] / 2)
	y = cnt[i] - x
	ans += int(x * (x - 1) / 2) + int(y * (y - 1) / 2)
print(ans)


from collections import Counter
n = int(input())
student = []
for i in range(n):
	student.append(input()[0])
d = Counter(student)
ans = 0
for k in d.values():
	temp1 = k // 2
	temp2 = k - temp1
	ans += temp1 * (temp1 - 1) // 2
	ans += temp2 * (temp2 - 1) // 2
print(ans)


n = int(input())
names = dict()
for _ in range(n):
	name = input().strip()
	if name[0] not in names:
		names[name[0]] = 0
	names[name[0]] += 1
cnt = 0
for (k, v) in names.items():
	prvi = v // 2
	drugi = v - prvi
	cnt += prvi * (prvi - 1) // 2
	cnt += drugi * (drugi - 1) // 2
print(cnt)


from math import *
n = int(input())
l = []
d = {}
for i in range(n):
	s = input()
	l.append(s[:1])
	d[s[:1]] = 0
for i in l:
	d[i] += 1
ans = 0
l = set(l)
for i in l:
	if d[i] != 1 and d[i] != 2:
		x = ceil(d[i] / 2)
		ans += x * (x - 1) // 2
		y = d[i] - x
		ans += y * (y - 1) // 2
print(ans)


n = int(input())
s = []
for i in range(n):
	ss = list(input())
	s.append(ord(ss[0]))
a = {}
for i in range(len(s)):
	if s[i] in a:
		p = a.get(s[i]) + 1
		a[s[i]] = p
	else:
		a[s[i]] = 1
s = list(a.values())
a = []
b = []
for i in range(len(s)):
	if s[i] <= 1:
		continue
	elif s[i] % 2 == 0:
		l = int(s[i] / 2)
		a.append(l)
		b.append(l)
	else:
		r = int(s[i] // 2)
		rr = int(s[i] % 2)
		a.append(r)
		b.append(r + rr)

def deti(c):
	x = 0
	for i in range(len(c)):
		x = x + c[i] * (c[i] - 1) / 2
	return int(x)
deti(a)
deti(b)
print(deti(a) + deti(b))


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
(n,) = map(int, sys.stdin.readline().split())
cs = collections.defaultdict(int)
for _ in range(n):
	s = input()
	cs[s[0]] += 1
ans = 0
for (k, v) in cs.items():
	m1 = v // 2
	m2 = v - m1
	ans += m1 * (m1 - 1) // 2
	ans += m2 * (m2 - 1) // 2
print(ans)


n = int(input())
a = []
dic = {}
for i in range(n):
	a.append(input())
	a[i] = a[i][0]
	if a[i] not in dic:
		dic[a[i]] = 1
	else:
		dic[a[i]] += 1
ctr = 0
for i in dic:
	x = dic[i] // 2
	y = dic[i] - x
	ctr += x * (x - 1) / 2 + y * (y - 1) / 2
print(int(ctr))


n = int(input())
names = []
for i in range(n):
	name = input()
	names.append(name[0])
uniq = set(names)
res = 0

def count(x):
	a = x // 2
	b = x - a
	return max(0, a * (a - 1) // 2) + max(0, b * (b - 1) // 2)
for u in uniq:
	res += count(names.count(u))
print(res)


n = int(input())

def ptn(v):
	if v == 1:
		return 0
	elif v == 2:
		return 1
	else:
		n = 1
		i = 1
		ct = 2
		while ct < v:
			i += 1
			n += i
			ct += 1
		return n
frq = {}
cls = {}
for i in range(n):
	nm = input('')
	if nm[0] not in frq:
		frq[nm[0]] = 0
	frq[nm[0]] += 1
frq2 = frq.copy()
cls['c1'] = ''
cls['c2'] = ''
for k in frq:
	i1 = 0
	i2 = 0
	while i1 + i2 < frq2[k] and frq[k] > 0:
		if k not in cls['c1']:
			cls['c1'] += k
			frq[k] -= 1
			i1 += 1
		elif k not in cls['c2']:
			cls['c2'] += k
			frq[k] -= 1
			i2 += 1
		elif i1 == i2:
			frq[k] -= 1
			cls['c1'] += k
			i1 += 1
		elif i1 > i2:
			frq[k] -= 1
			cls['c2'] += k
			i2 += 1
		else:
			pass
frq3 = {k: 0 for k in frq2}
frq4 = frq3.copy()
for lt in frq3:
	if lt in cls['c1']:
		frq3[lt] += ptn(cls['c1'].count(lt))
	if lt in cls['c2']:
		frq4[lt] += ptn(cls['c2'].count(lt))
print(sum(frq3.values()) + sum(frq4.values()))


from itertools import groupby
import math
n = int(input())
first = []
for _ in range(n):
	first.append(input()[0])

def NCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
first.sort()
c = 0
for (i, j) in groupby(first):
	(letter, size) = (i, len(list(j)))
	ans = []
	if size / 2 > 1:
		ans = [size // 2, size - size // 2]
		for k in ans:
			if k > 1:
				c += NCr(k, 2)
print(c)


n = int(input())
x = []
for i in range(n):
	a = input()
	x.append(a)
z = []
for i in range(n):
	y = []
	if x[i] != [0]:
		y.append(x[i])
		for j in range(i + 1, n):
			if x[i][0] == x[j][0]:
				if x[j] != [0]:
					y.append(x[j])
				x[j] = [0]
		x[i] = [0]
		z.append(y)
s = 0
for i in range(len(z)):
	if len(z[i]) // 2 > 1:
		if len(z[i]) > 4:
			if len(z[i]) % 2 != 0:
				s += (len(z[i]) // 2) ** 2
			else:
				s += len(z[i]) // 2 * (len(z[i]) // 2 - 1)
		else:
			s += len(z[i]) // 2
	elif len(z[i]) == 3:
		s += 1
print(s)


from collections import defaultdict
from math import factorial
hash = defaultdict(int)
n = int(input())
l = []
k = []
for i in range(n):
	st = input()
	l.append(st)
	hash[st[0]] += 1
for i in hash.keys():
	k.append(hash[i])
k.sort(reverse=True)
sum = 0
for i in range(len(k)):
	z1 = k[i] // 2
	z2 = k[i] - z1
	if z1 >= 2:
		sum += factorial(z1) // (factorial(z1 - 2) * factorial(2))
	if z2 >= 2:
		sum += factorial(z2) // (factorial(z2 - 2) * factorial(2))
print(sum)


x = int(input())
l = []
while x:
	l.append(input())
	x = x - 1
l1 = []
for i in range(len(l)):
	s = list(l[i])
	l1.append(s[0])
s1 = list(set(l1))
l2 = []
for i in range(len(s1)):
	l2.append(l1.count(s1[i]))
su = 0
for i in range(len(l2)):
	if l2[i] % 2 == 0:
		ans = l2[i] // 2
		su += 2 * (ans * (ans - 1) // 2)
	else:
		ans1 = l2[i] // 2
		ans2 = l2[i] - ans1
		su += ans1 * (ans1 - 1) // 2
		su += ans2 * (ans2 - 1) // 2
print(su)


n = int(input())
a = []
b = []
st = set()
for _ in range(n):
	s = str(input())
	st.add(s[0])
	if a.count(s[0]) == 0:
		a.append(s[0])
	elif b.count(s[0]) == 0:
		b.append(s[0])
	elif a.count(s[0]) < b.count(s[0]):
		a.append(s[0])
	else:
		b.append(s[0])
ans = 0
for c in list(st):
	ans += a.count(c) * (a.count(c) - 1) // 2
	ans += b.count(c) * (b.count(c) - 1) // 2
print(ans)


import math
n = int(input())
names = [input() for _ in range(n)]
gby = dict()
for name in names:
	k = name[0]
	v = gby.get(k, [])
	v.append(name)
	gby[k] = v
result = 0
for (k, v) in gby.items():
	l = math.floor(len(v) / 2)
	r = math.ceil(len(v) / 2)
	result += l * (l - 1) + r * (r - 1)
print(result // 2)


import math
d = {}
n = int(input())
for i in range(n):
	x = input()
	if x[0] not in d:
		d[x[0]] = 1
	else:
		d[x[0]] += 1
res = 0
for i in d:
	c = math.ceil(d[i] / 2)
	f = math.floor(d[i] / 2)
	res = res + c * (c - 1) // 2 + f * (f - 1) // 2
print(res)


n = int(input())

def nCr(n, r):
	if n < r:
		return 0
	if n == 0:
		return 0
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
d = []
for i in range(n):
	a = input()
	d.append(a[0])
ans = 0
ar = []
s = list(set(d))
if len(s) == 1:
	if n % 2 == 0:
		f = n // 2
		ans = f * (f - 1)
	else:
		f = n // 2
		g = f + 1
		ans = f * (f - 1) // 2 + g * (g - 1) // 2
	print(ans)
	exit()
for i in s:
	ar.append(d.count(i))
for i in ar:
	if i % 2 == 0:
		f = i // 2
		ans += 2 * nCr(f, 2)
	else:
		f = i // 2
		g = f + 1
		ans += nCr(f, 2) + nCr(g, 2)
print(int(ans))


import itertools
from collections import defaultdict

def f(d2):
	return d2 * (d2 - 1) // 2

def main():
	n = int(input())
	data = defaultdict(lambda : 0)
	for i in range(n):
		data[input()[0]] += 1
	c = 0
	for (k, v) in data.items():
		d1 = v // 2
		d2 = v - d1
		c += f(d1) + f(d2)
	print(c)
main()


l = [0] * 1000

def pairs(n):
	return n * (n - 1) // 2
for i in range(3, 1000):
	if i % 2:
		l[i] = pairs((i + 1) // 2) + pairs((i - 1) // 2)
	else:
		l[i] = pairs(i // 2) + pairs(i // 2)
m = [0] * 200
n = int(input())
for i in range(n):
	name = input()
	m[ord(name[0])] += 1
ans = 0
for i in m:
	if i > 0:
		ans += l[i]
print(ans)


import math

def ncr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
N = int(input())
a = []
arr = []
for i in range(26):
	arr.append(0)
for i in range(N):
	temp = input()
	temp = temp[0]
	arr[ord(temp) - 97] += 1
min = 0
for i in range(26):
	if arr[i] == 3:
		min += 1
	elif arr[i] > 3:
		m = 0
		if arr[i] % 2 == 0:
			m = 2 * ncr(arr[i] / 2, 2)
		else:
			x = arr[i] // 2
			y = (arr[i] + 1) / 2
			m = ncr(x, 2) + ncr(y, 2)
		min += m
print(int(min))


t = int(input())
b = [0] * 26
list = []
sum = 0
for i in range(t):
	a = input()
	list.append(a)
for i in range(t):
	b[ord(list[i][0]) - 97] += 1
b.sort(reverse=True)
for i in range(26):
	if b[i] > 1:
		te = b[i] // 2
		te1 = b[i] - te
		sum += te * (te - 1) / 2 + te1 * (te1 - 1) / 2
	else:
		break
print(int(sum))


nre = int(input())
lre = [0] * 1000
for i in range(nre):
	str = input()
	lre[ord(str[0])] += 1
lolly = 0
for i in range(1000):
	if lre[i] % 2 == 0:
		lolly += lre[i] // 2 * (lre[i] // 2 - 1)
	else:
		lolly += lre[i] // 2 * (lre[i] // 2 - 1) // 2
		lolly += (lre[i] + 1) // 2 * ((lre[i] + 1) // 2 - 1) // 2
print(lolly)


n = int(input())
A = [input() for i in range(n)]
letters = {}
for e in A:
	if e[0] not in letters.keys():
		letters[e[0]] = 1
	else:
		letters[e[0]] += 1
sum = 0
for e in letters.values():
	a = e // 2
	b = e - a
	if a > 0:
		a = a * (a - 1) // 2
	if b > 0:
		b = b * (b - 1) // 2
	sum += a
	sum += b
print(sum)


p = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
test = int(input())
for i in range(test):
	s = input()
	key = s[0]
	p[key] = p[key] + 1
g1 = []
g2 = []
count = 0
keys = list(p.keys())
for i in keys:
	val = p[i]
	if val > 0:
		s1 = val // 2
		s2 = val - s1
		count = count + s1 * (s1 - 1) // 2
		count = count + s2 * (s2 - 1) // 2
print(count)


n = int(input())
sp = [0] * 26
for i in range(n):
	st = input()
	sp[ord(st[0]) - ord('a')] += 1
sm = 0
for x in sp:
	ch = x // 2
	sm += ch * (ch - 1) // 2
	sm += (x - ch) * (x - ch - 1) // 2
print(sm)


n = int(input())
l = [0] * 200
while n != 0:
	s = input()
	l[ord(s[0])] += 1
	n -= 1
ans = 0
for i in l:
	if i > 0:
		T1 = i // 2
		T2 = i - i // 2
		ans += T1 * (T1 - 1) // 2 + T2 * (T2 - 1) // 2
print(ans)


n = int(input())
x = 0
count = dict()
for _ in range(n):
	a = input()[0]
	if a in count:
		count[a] += 1
	else:
		count[a] = 1
for a in count.keys():
	if count[a] > 2:
		first = count[a] // 2
		second = count[a] - first
		x += first * (first - 1) // 2
		x += second * (second - 1) // 2
print(x)


n = int(input())
a = [0 for i in range(ord('z') + 1)]
for i in range(n):
	a[ord(input()[0])] += 1
x = 0
for c in a:
	if c == 0:
		continue
	k1 = c // 2
	if c % 2 == 0:
		k2 = k1
	else:
		k2 = k1 + 1
	x += k1 * (k1 - 1) // 2 + k2 * (k2 - 1) // 2
print(x)


def Cn2(n):
	return n * (n - 1) // 2
n = int(input())
d = {}
for _ in range(n):
	s = input()
	d[s[0]] = d.get(s[0], 0) + 1
ans = 0
for x in d.values():
	ans += Cn2(x // 2) + Cn2(x - x // 2)
print(ans)


n = int(input())
l = [0] * 26
for i in range(n):
	s = list(input())
	l[ord(s[0]) % 97] += 1
count = 0
for i in range(26):
	if l[i] % 2 == 0:
		k = l[i] // 2
		if k <= 1:
			pass
		else:
			count += 2 * k * (k - 1) // 2
	else:
		k1 = l[i] // 2 + 1
		k2 = l[i] // 2
		if k1 > 1:
			count += k1 * (k1 - 1) // 2
		if k2 > 1:
			count += k2 * (k2 - 1) // 2
print(count)


def sum_seq(q):
	ans = 0
	for j in range(1, q):
		ans += j
	return ans
n = int(input())
s = set()
a = []
ans = []
for i in range(n):
	x = input()
	a.append(x[0])
	if x[0] not in s:
		s.add(x[0])
for j in range(len(list(s))):
	ans.append(a.count(list(s)[j]))
abc = 0
for k in range(len(ans)):
	if ans[k] > 2:
		if ans[k] % 2 == 0:
			abc += 2 * sum_seq(ans[k] // 2)
		else:
			abc += sum_seq(ans[k] // 2) + sum_seq(ans[k] // 2 + 1)
print(abc)


import operator as op
from functools import reduce

def choose(n, k):
	k = min(k, n - k)
	numer = reduce(op.mul, range(n, n - k, -1), 1)
	denom = reduce(op.mul, range(1, k + 1), 1)
	return numer // denom

def get_min_chatty_pairs(n, names):
	alpha = dict()
	for i in range(97, 97 + 26):
		alpha[chr(i)] = 0
	x = 0
	for name in names:
		alpha[name[0]] += 1
	for key in alpha.keys():
		p1 = alpha[key] // 2
		p2 = alpha[key] - p1
		if p1 > 1:
			x += choose(p1, 2)
		if p2 > 1:
			x += choose(p2, 2)
	return x
N = int(input())
names = list()
for _ in range(N):
	names.append(input())
print(get_min_chatty_pairs(N, names))


n = int(input())
class1 = {}
class2 = {}

def fatorial(n):
	if n == 1 or n == 0:
		return 1
	return fatorial(n - 1) * n
for i in range(n):
	s = input()
	if s[0] not in class1 and s[0] not in class2:
		class1[s[0]] = 1
	elif s[0] in class1 and s[0] in class2:
		if class1[s[0]] > class2[s[0]]:
			class2[s[0]] += 1
		else:
			class1[s[0]] += 1
	elif s[0] in class1:
		class2[s[0]] = 1
ans = 0
for i in class1:
	if class1[i] > 1:
		ans += fatorial(class1[i]) // (fatorial(class1[i] - 2) * 2)
for i in class2:
	if class2[i] > 1:
		ans += fatorial(class2[i]) // (fatorial(class2[i] - 2) * 2)
print(ans)


n = int(input())
dict1 = {}
for i in range(n):
	s = str(input())
	try:
		dict1[s[0]] += 1
	except:
		KeyError
		dict1[s[0]] = 1
ans = 0
for i in list(dict1.keys()):
	if dict1[i] > 2:
		val1 = dict1[i] // 2
		val2 = dict1[i] // 2 + dict1[i] % 2
		if val1 > 0:
			ans += val1 * (val1 - 1) // 2
		if val2 > 0:
			ans += val2 * (val2 - 1) // 2
print(ans)


n = int(input())
a = [0] * 26
for i in range(n):
	s = input()
	j = ord(s[0]) - 97
	a[j] += 1
ans = 0
for i in range(26):
	if a[i] != 0:
		k = a[i] // 2
		l = a[i] - k
		ans += k * (k - 1) // 2
		ans += l * (l - 1) // 2
print(ans)


import math
n = int(input())
(l, c) = ([], 0)
for _ in range(n):
	s = input()
	l.append(s[0])

def foo(x):
	f = math.factorial
	return f(x) // f(2) // f(x - 2)
l.sort()
g = list(set(l))
for i in g:
	d = l.count(i)
	if d == 3:
		c += foo(2)
	elif d > 3:
		c += foo(d // 2) + foo(d - d // 2)
print(c)


n = int(input())
d = {}
for i in range(n):
	s = input().strip()[0]
	if s not in d:
		d[s] = 0
	d[s] += 1
ans = 0
for key in d.keys():
	if d[key] <= 2:
		continue
	else:
		gr1 = d[key] // 2
		gr2 = d[key] - gr1
		ans += gr1 * (gr1 - 1) // 2 + gr2 * (gr2 - 1) // 2
print(ans)


n = int(input())
x = {}
for i in range(n):
	l = input()
	try:
		x[l[0]].append(l)
	except:
		x[l[0]] = [l]
p = 0
for (k, v) in x.items():
	a = len(v) // 2
	b = len(v) - a
	p += (a - 1) * a / 2
	p += (b - 1) * b / 2
print(int(p))


import math
import re
import sys
from collections import defaultdict
from heapq import heappush, heappop
from fractions import gcd

def read(type=int):
	return type(input())

def read_list(type=int, split=' ', F=None):
	if F:
		return map(lambda x: F(type(x)), raw_input().split(split))
	return map(type, input().split(split))

def read_list_of_list(N, type=int, split=' ', F=None):
	return [read_list(type, F=F) for _ in range(N)]
n = read()
C = defaultdict(int)
for _ in range(n):
	C[read(str)[0]] += 1
R = 0

def comb(n):
	return n * (n - 1) // 2
for c in C:
	R += comb(C[c] // 2)
	R += comb((C[c] + 1) // 2)
print(R)


def c2(x):
	if x == 0 or x == 1:
		return 0
	else:
		return x * (x - 1) // 2
n = int(input())
s = []
cnt = [0 for i in range(26)]
for i in range(n):
	s1 = input()
	cnt[ord(s1[0]) - ord('a')] += 1
ans = 0
for i in range(26):
	x = cnt[i] // 2
	ans += c2(x) + c2(cnt[i] - x)
print(ans)


from math import factorial

def comb(n):
	a = factorial(n) / (2 * factorial(n - 2))
	return a
n = int(input())
names = []
let = ['a']
freq = dict()
for i in range(1, 26):
	let.append(chr(ord(let[i - 1]) + 1))
for x in let:
	freq[x] = 0
for i in range(n):
	names.append(str(input())[0])
	freq[names[i]] += 1
ans = 0
for x in freq.keys():
	if freq[x] <= 2:
		continue
	elif freq[x] == 3:
		ans += 1
	elif freq[x] == 4:
		ans += 2
	else:
		ans += comb(freq[x] // 2) + comb(freq[x] // 2 + freq[x] % 2)
print(int(ans))


import math

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
n = int(input())
d = {}
l = []
for i in range(n):
	l.append(input()[0])
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
ans = 0
for i in d.keys():
	(a, b) = (0, 0)
	if d[i] % 2 == 0:
		a = d[i] // 2
		b = d[i] // 2
	else:
		a = d[i] // 2
		b = a + 1
	if a > 1:
		ans += math.ceil(nCr(a, 2))
	if b > 1:
		ans += math.ceil(nCr(b, 2))
print(ans)


from itertools import combinations
import math
n = int(input())

def combi(lst):
	return len(list(combinations(list(range(lst)), 2)))
students = dict()
for _ in range(n):
	a = input()[0]
	if a not in students.keys():
		students[a] = 1
	else:
		students[a] += 1
result = 0
for key in students.keys():
	if students[key] > 1:
		k = students[key]
		result = result + combi(math.ceil(k / 2)) + combi(math.floor(k / 2))
print(result)


import math
n = int(input())
s = []
d = {}
res = 0
for i in range(n):
	x = input()
	s.append(x[0])
	d[x[0]] = 0
for i in range(n):
	d[s[i]] += 1
for i in list(d.keys()):
	if d[i] > 2:
		g1 = math.floor(d[i] / 2)
		g2 = math.ceil(d[i] / 2)
		res += g1 * (g1 - 1) // 2
		res += g2 * (g2 - 1) // 2
print(res)


n = int(input())
c = {}
cp = 0
for x in range(n):
	s = input()
	if s[0] not in c.keys():
		c[s[0]] = 1
	else:
		c[s[0]] += 1
for y in c.values():
	c1 = y // 2
	c2 = y - y // 2
	c1 -= 1
	c2 -= 1
	while c1 > 0:
		cp += c1
		c1 -= 1
	while c2 > 0:
		cp += c2
		c2 -= 1
print(cp)


import math

def comb(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
n = int(input())
lst = [x for i in range(n) for x in input().split()]
lst1 = {chr(key): 0 for key in range(97, 123)}
for i in lst:
	lst1[i[0]] += 1
f = 0
c = 0
count = 0
for i in lst1.values():
	f = math.floor(i / 2)
	c = math.ceil(i / 2)
	if f > 1:
		count += comb(f, 2)
	if c > 1:
		count += comb(c, 2)
print(int(count))


import sys
input = sys.stdin.readline
n = int(input())
l = [0] * 26
for i in range(n):
	s = input()
	l[ord(s[0]) - 97] += 1
ans = 0
for i in range(26):
	cur = l[i] // 2
	nex = l[i] - cur
	ans += cur * (cur - 1) // 2
	ans += nex * (nex - 1) // 2
print(ans)


import math

def binomialCoef(n, k):
	C = [[0 for x in range(k + 1)] for x in range(n + 1)]
	for i in range(n + 1):
		for j in range(min(i, k) + 1):
			if j == 0 or j == i:
				C[i][j] = 1
			else:
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j]
	return C[n][k]
n = int(input())
a = [None] * n
d = dict()
for i in range(n):
	a[i] = input()
	a = list(a)
	try:
		d[a[i][0]] += 1
	except:
		d[a[i][0]] = 1
mp = 0
for i in d.values():
	mp += binomialCoef(int(math.ceil(i / 2)), 2)
	mp += binomialCoef(int(math.floor(i / 2)), 2)
print(mp)


n = int(input())
d = {}
for i in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] = d[s[0]] + 1
	else:
		d[s[0]] = 1
ans = 0
for i in d:
	if d[i] == 3:
		ans = ans + 1
	elif d[i] == 4:
		ans = ans + 2
	elif d[i] == 5:
		ans = ans + 4
	elif d[i] > 2:
		ans = ans + (d[i] // 2 - 1) * (d[i] // 2) + d[i] % 2 * (d[i] // 2)
	else:
		ans = ans
print(ans)


import math

def nCr(n, r):
	if n <= 1:
		return 0
	return math.factorial(n) // math.factorial(r) // math.factorial(n - r)
n = int(input())
name = []
for q in range(n):
	name.append(input())
name.sort()
count = [0 for x in range(26)]
for q in name:
	count[ord(q[0]) - 97] += 1
ans = 0
for q in range(len(count)):
	one = count[q] // 2
	two = count[q] - count[q] // 2
	ans += nCr(one, 2) + nCr(two, 2)
print(ans)


t = int(input())
names = []
for _ in range(t):
	names.append(input())
l1 = []
l2 = []
for name in names:
	if name[0] in l1:
		if name[0] in l2:
			if l1.count(name[0]) > l2.count(name[0]):
				l2.append(name[0])
			else:
				l1.append(name[0])
		else:
			l2.append(name[0])
	else:
		l1.append(name[0])
count1 = 0
for i in range(0, len(l1)):
	for j in range(i + 1, len(l1)):
		if l1[i] == l1[j]:
			count1 = count1 + 1
count2 = 0
for i in range(0, len(l2)):
	for j in range(i + 1, len(l2)):
		if l2[i] == l2[j]:
			count2 = count2 + 1
print(count1 + count2)


n = int(input())
name = []
for i in range(n):
	name.append(input())
table = {}
for i in range(n):
	if name[i][0:1] not in table:
		table[name[i][0:1]] = 1
	else:
		table[name[i][0:1]] += 1
res = 0
for (key, value) in table.items():
	room1 = value // 2
	room2 = value - room1
	combi = room1 * (room1 - 1) / 2 + room2 * (room2 - 1) / 2
	res += combi
print(int(res))


import math
n = int(input())
c = {}
for i in range(n):
	x = input()
	if x[0] in c:
		c[x[0]] += 1
	else:
		c[x[0]] = 1
p = 0
for i in c.values():
	a = math.ceil(i / 2)
	b = math.floor(i / 2)
	p += (a * (a - 1) + b * (b - 1)) // 2
print(p)


def fact(n):
	res = 1
	i = 2
	while i <= n:
		res = res * i
		i += 1
	return res

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))
n = int(input())
cnt = list()
for i in range(27):
	cnt.append(int(0))
while int(n) > 0:
	s = input()
	cnt[ord(s[0]) - 97] += 1
	ans = 0
	i = 0
	while i < 27:
		if cnt[i] > 0:
			g1 = nCr(int(cnt[i] + 1) / 2, 2)
			g2 = nCr(int(cnt[i] / 2), 2)
			ans += int(g1) + int(g2)
		i += 1
	n = n - 1
print(ans)


n = int(input())
ch = [0] * 30
for i in range(n):
	s = input()
	ch[ord(s[0]) - ord('a')] += 1
ans = 0
for i in ch:
	ans += i // 2 * (i // 2 - 1) // 2
	j = i - i // 2
	ans += j * (j - 1) // 2
print(ans)


from collections import Counter
n = int(input())
stud = []
for i in range(n):
	a = input()
	stud.append(ord(a[0]) - 97)
stud = Counter(stud)
ans = 0
for j in stud:
	p = stud[j]
	if p > 2:
		m = p // 2
		ans += m * (m - 1)
		if p % 2 != 0:
			ans += m
print(ans)


from math import factorial
n = int(input())
d = {}
for i in range(n):
	s = list(input())[0]
	if not s in d:
		d[s] = 0
	d[s] += 1
r = 0
for e in d:
	if d[e] > 2:
		x = d[e] // 2
		if x == 1:
			r += 1
			continue
		y = x
		if d[e] % 2:
			y += 1
		r += sum(list(range(1, x))) + sum(list(range(1, y)))
print(r)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
d = {}
count = 0
for i in range(n):
	c = get_string()[0]
	if c in d:
		d[c] += 1
	else:
		d[c] = 1
for v in d.values():
	if v > 2:
		half_1 = v // 2
		half_2 = v - half_1
		count += half_1 * (half_1 - 1) // 2 + half_2 * (half_2 - 1) // 2
print(count)


n = int(input())
letters = {}
for _ in range(n):
	name = input()
	fc = name[0]
	if fc not in letters:
		letters[fc] = 1
	else:
		letters[fc] += 1
res = 0
for (k, v) in letters.items():
	c1 = v // 2
	c2 = v - c1
	res += c1 * (c1 - 1) + c2 * (c2 - 1)
print(res // 2)


def bino(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res // (i + 1)
	return res
k = []
for i in range(0, int(input())):
	p = list(input())
	k.append(p[0])
u = {}
for i in range(0, len(k)):
	if k[i] not in u:
		u[k[i]] = 1
	else:
		u[k[i]] += 1
t = 0
w = 0
for i in u:
	x = u[i]
	y = x // 2
	e = x - y
	if y > 1:
		w += bino(y, 2)
	if e > 1:
		w += bino(e, 2)
print(w)


from collections import Counter
import math

def choose2(a):
	if a < 2:
		return 0
	fact = math.factorial
	return fact(a) // 2 // fact(a - 2)
n = int(input())
class1 = []
class2 = Counter()
for i in range(n):
	class1.append(input()[0])
class1 = Counter(class1)
for student in class1:
	if class1[student] > 1:
		class2.update({student: class1[student] // 2})
		class1[student] -= class1[student] // 2
x = sum(map(choose2, class1.values()))
x += sum(map(choose2, class2.values()))
print(x)


n = int(input())
name = [input() for i in range(0, n)]
check = []
out = 0
for i in range(0, n):
	check.append(name[i][0])
check.sort()
i = 0
while i < n:
	a = check.count(check[i])
	if a % 2 == 1:
		b = a // 2 + 1
	else:
		b = a // 2
	c = a - b
	out = out + b * (b - 1) // 2 + c * (c - 1) // 2
	i = i + a
print(out)


def chatty(N):
	return sum((e for e in range(1, N)))
n = int(input())
a = []
b = []
for i in range(n):
	s = input()
	a.append(s)
k = 0
while k < 26:
	c = 0
	for i in range(len(a)):
		if a[i][0] == chr(97 + k):
			c = c + 1
	b.append(c)
	k = k + 1
c = 0
p1 = 0
p2 = 0
for i in range(len(b)):
	if b[i] > 2:
		p1 = b[i] // 2
		p2 = b[i] - p1
		c = c + (chatty(p1) + chatty(p2))
print(c)


import sys
import math
import bisect

def main():
	d = dict()
	for _ in range(int(input())):
		s = input()
		c = s[0]
		if c not in d:
			d[c] = 0
		d[c] += 1
	ans = 0
	for a in d.values():
		n1 = a // 2
		n2 = a // 2 + a % 2
		ans += n1 * (n1 - 1) // 2
		ans += n2 * (n2 - 1) // 2
	print(ans)
main()


import math

def nCr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
dict1 = {}
dict2 = {}
for _ in range(int(input())):
	word = input()
	if word[0] not in dict1:
		dict1[word[0]] = 1
	elif word[0] not in dict2:
		dict2[word[0]] = 1
	elif dict1[word[0]] < dict2[word[0]]:
		dict1[word[0]] += 1
	else:
		dict2[word[0]] += 1
pairs = 0
for value in dict1.values():
	if value > 1:
		pairs += nCr(value, 2)
for value in dict2.values():
	if value > 1:
		pairs += nCr(value, 2)
print(int(pairs))


import math
import sys
firstLine = True
dict1 = {}
minPairs = 0
for line in sys.stdin:
	if firstLine:
		numTests = int(line)
		firstLine = False
		continue
	line = line.strip()
	a = line[0]
	if a not in dict1:
		dict1[a] = 1
	else:
		dict1[a] += 1
for x in dict1:
	if dict1[x] % 2 == 0 and dict1[x] != 2:
		num1 = dict1[x] / 2
		r = 2
		minPairs += 2 * (math.factorial(num1) / (math.factorial(r) * math.factorial(num1 - r)))
	elif dict1[x] % 2 != 0 and dict1[x] != 1:
		num1 = (dict1[x] + 2 - 1) // 2
		num2 = dict1[x] - num1
		list1 = []
		list1.append(num1)
		list1.append(num2)
		r = 2
		for i in range(2):
			if list1[i] != 1:
				minPairs += math.factorial(list1[i]) / (math.factorial(r) * math.factorial(list1[i] - r))
print(int(minPairs))


from string import ascii_lowercase
from math import factorial
n = int(input())
names = []
for x in range(0, n):
	names.append(input()[0])
counts = []
for letter in ascii_lowercase:
	count = names.count(letter)
	if count:
		counts.append(count)

def countnos(n, r):
	return factorial(n) / (factorial(r) * factorial(n - r))
chattypairs = 0
for count in counts:
	if count > 2:
		if count % 2 == 0:
			cp = countnos(count / 2, 2)
			chattypairs = chattypairs + cp * 2
		else:
			cp2 = countnos(int(count / 2) + 1, 2)
			if count != 3:
				cp1 = countnos(int(count / 2), 2)
				chattypairs = chattypairs + cp1 + cp2
			else:
				chattypairs = chattypairs + cp2
print(int(chattypairs))


from collections import Counter
n = int(input())
l = []
for i in range(n):
	l += [list(input())]
a = [i[0] for i in l]
c = Counter(a)
count = 0
for i in c:
	if c[i] > 2:
		if c[i] % 2 == 0:
			c[i] = c[i] // 2
			count += c[i] * (c[i] - 1)
		else:
			r = (c[i] + 1) // 2
			r1 = (c[i] - 1) // 2
			count += r * (r - 1) // 2 + r1 * (r1 - 1) // 2
print(count)


dp = [[0 for i in range(102)] for j in range(102)]
for i in range(101):
	dp[i][0] = 1
for i in range(1, 101):
	for j in range(1, 3):
		dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
n = int(input())
d = {}
for _ in range(n):
	x = input()
	d[x[0]] = d.get(x[0], 0) + 1
ans = 0
for i in d:
	k1 = d[i]
	k2 = k1 // 2
	ans += dp[k2][2] + dp[k1 - k2][2]
print(ans)


def factorial(x):
	if x == 1:
		return 1
	else:
		return x * factorial(x - 1)

def func(x):
	if x > 2:
		return factorial(x) / (factorial(x - 2) * 2)
	elif x == 2:
		return 1
	else:
		return 0
t = int(input())
n = []
f = []
total = 0
index = 0
for _ in range(26):
	f.append(0)
for _ in range(t):
	m = input()
	f[ord(m[0]) - 97] += 1
while index < 26:
	if f[index] == 0:
		total = total
	elif f[index] % 2 == 0:
		x = f[index] / 2
		total += 2 * func(x)
	else:
		x = int(f[index] / 2)
		total += func(x) + func(x + 1)
	index += 1
print(int(total))


import bisect
from collections import Counter
n = int(input())
s = []
d = [0] * 26
for i in range(n):
	t = input()
	s.append(t[0])
	d[ord(t[0]) - ord('a')] += 1
cnt = 0
for i in range(26):
	if d[i] <= 2:
		continue
	if d[i] % 2 == 0:
		cnt += d[i] // 2 * (d[i] // 2 - 1)
	else:
		cnt += (d[i] - 1) // 2 + (d[i] - 1) // 2 * ((d[i] - 1) // 2 - 1)
print(cnt)


a = int(input())
dic = {}
for _ in range(a):
	b = input()
	if b[0] in dic:
		dic[b[0]] += 1
	else:
		dic[b[0]] = 1
r = 0
for i in dic.keys():
	t = dic[i] // 2
	p = dic[i] - t
	r += t * (t - 1) / 2
	r += p * (p - 1) / 2
print(int(r))


import math
x = []
counter = 0
for i in range(int(input())):
	s = str(input())
	x.append(s[0])
y = list(set(x))
for j in y:
	if x.count(j) > 2:
		n = math.ceil(x.count(j) / 2)
		if x.count(j) % 2 == 0:
			counter += n * (n - 1)
		else:
			counter += n * (n - 1) // 2
			counter += (n - 1) * (n - 2) // 2
print(counter)


def nc2(n):
	if n > 2:
		return n * (n - 1) // 2
	elif n == 1:
		return 0
	elif n == 2:
		return 1
t = int(input())
names = []
for _ in range(t):
	s = input()
	names.append(s)
class_1 = []
class_2 = []
names.sort()
for i in range(t):
	if i % 2:
		class_1.append(names[i])
	else:
		class_2.append(names[i])
x = 0
d = {}
for i in class_1:
	if i[0] in d:
		d[i[0]] += 1
	else:
		d[i[0]] = 1
for i in d.keys():
	x += nc2(d[i])
e = {}
for i in class_2:
	if i[0] in e:
		e[i[0]] += 1
	else:
		e[i[0]] = 1
for i in e.keys():
	x += nc2(e[i])
print(x)


x = 0
l1 = []
l2 = []
for i in range(int(input())):
	s = input()
	if s[0] not in l1:
		l1.append(s[0])
	elif s[0] not in l2:
		l2.append(s[0])
	elif l1.count(s[0]) < l2.count(s[0]):
		l1.append(s[0])
	else:
		l2.append(s[0])
q = set(l1)
for i in q:
	p = l1.count(i)
	r = l2.count(i)
	x += p * (p - 1) / 2 + r * (r - 1) / 2
print(int(x))


d = dict()
for _ in range(int(input())):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
ans = 0
for i in d:
	if d[i] > 2:
		n1 = d[i] // 2
		ans += (d[i] - n1) * (d[i] - n1 - 1) // 2 + n1 * (n1 - 1) // 2
print(ans)


import sys
from collections import Counter

def numofpairs(n):
	return n * (n - 1) // 2
n = int(sys.stdin.readline().strip())
namecounter = Counter((name[0] for line in sys.stdin.readlines() for name in line.split()))
print(sum((numofpairs(n // 2) + numofpairs((n + 1) // 2) for n in namecounter.values())))


n = int(input())
a = []
b = []
pars = 0
count = 1

def pary(per):
	if per == 0:
		return 0
	elif per == 1:
		return 0
	else:
		e = per - 1 + pary(per - 1)
	return e
for i in range(n):
	c = list(input())
	a.append(c[0])
a.sort()
for i in range(1, n):
	if a[i] == a[i - 1]:
		count += 1
	else:
		b.append(count)
		count = 1
b.append(count)
for i in range(len(b)):
	q = b[i] // 2
	w = b[i] - q
	q = pary(q)
	w = pary(w)
	pars += q + w
print(pars)


n = int(input())
aux_dict = {}
a = []
for i in range(n):
	a.append(input())
for i in range(len(a)):
	temp = a[i][0]
	if temp not in aux_dict:
		aux_dict[temp] = 1
	else:
		aux_dict[temp] = aux_dict[temp] + 1
res = 0
for y in aux_dict:
	x = aux_dict[y]
	if x == 1:
		res += 0
	elif x % 2 == 0:
		res += x // 2 * (x // 2 - 1)
	else:
		res += x // 2 * (x // 2 - 1) / 2
		res += (x // 2 + 1) * (x // 2) / 2
res = int(res)
print(res)


n = int(input())
x = []
fn = []
co = []
for i in range(n):
	x.append(input())
	fn.append(x[i][0])
se = list(set(fn))
for i in range(len(se)):
	if fn.count(se[i]) > 2:
		co.append(fn.count(se[i]))
c = 0
for i in range(len(co)):
	e = co[i]
	k = co[i] // 2
	c += k * (k - 1) // 2 + (e - k) * (e - k - 1) // 2
print(c)


import math

def ncr(n, r):
	if n >= 2:
		numer = math.factorial(n)
		denom = math.factorial(r) * math.factorial(n - r)
		out = numer / denom
	else:
		out = 0
	return out
num = int(input())
names = []
for i in range(num):
	name = input()
	names.extend([name])
class1 = []
class2 = []
for i in range(1, 27):
	class1.append([i, 0])
	class2.append([i, 0])
for i in range(num):
	letter = ord(names[i][0]) - 96
	if class1[letter - 1][1] < class2[letter - 1][1]:
		class1[letter - 1][1] += 1
	else:
		class2[letter - 1][1] += 1
pairs = 0
for i in range(len(class1)):
	n1 = class1[i][1]
	n2 = class2[i][1]
	pairs += ncr(n1, 2) + ncr(n2, 2)
print(int(pairs))


n = int(input())
freq = {chr(c + 97): 0 for c in range(26)}

def nc2(n):
	return n * (n - 1) // 2
for _ in range(n):
	s = input()[0]
	freq[s] += 1
ans = 0
for c in freq:
	left = freq[c] // 2
	right = freq[c] - left
	ans += nc2(left) + nc2(right)
print(ans)


def classroom(names):
	letters = {}
	for i in names:
		if i[0] in letters:
			letters[i[0]] += 1
		else:
			letters[i[0]] = 1
	di = {}
	ans = 0
	for i in letters.values():
		if i & 1 == 1:
			m = i // 2
			l = m + 1
			if m not in di:
				di[m] = find_pairs(m)
			ans += di[m]
			if l not in di:
				di[l] = find_pairs(l)
			ans += di[l]
		else:
			m = i // 2
			l = m
			if m not in di:
				di[m] = find_pairs(m)
			ans += di[m]
			if l not in di:
				di[l] = find_pairs(l)
			ans += di[l]
	return ans

def find_pairs(n):
	m = n - 1
	return m * (m + 1) // 2
n = int(input())
names = []
for i in range(n):
	names.append(input())
print(classroom(names))


def calcularCombinacao(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - k + i) / i
	return int(res)
letras = {}
numAlunos = int(input())
i = 0
while i < numAlunos:
	aluno = input()
	if letras.get(aluno[0]) == None:
		letras[aluno[0]] = 1
	else:
		letras[aluno[0]] += 1
	i += 1
res = 0
for quantidade in letras.values():
	quantidadeTurma1 = quantidade // 2
	res += calcularCombinacao(quantidadeTurma1, 2)
	res += calcularCombinacao(quantidade - quantidadeTurma1, 2)
print(res)


import collections
n = int(input())
l = []
while n:
	m = input()
	l.append(m[0])
	n -= 1
l = collections.Counter(l)
k = list(l.values())
ma = 0
for i in range(0, len(k)):
	u = k[i] // 2
	v = k[i] - u
	ma += u * (u - 1) // 2 + v * (v - 1) // 2
print(ma)


from collections import Counter
n = int(input())
counts = Counter()
for _ in range(n):
	name = input()
	counts[name[0]] += 1
ans = 0
for (letter, count) in counts.items():
	a = count // 2
	b = count - a
	ans += a * (a - 1) // 2
	ans += b * (b - 1) // 2
print(ans)


d = {}
c = 0
n = int(input())
while n > 0:
	a = input()
	a = list(a)
	if a[0] not in d:
		d[a[0]] = 1
	else:
		d[a[0]] += 1
	n -= 1
for i in d.values():
	if i > 2:
		if i % 2 == 0:
			i = i // 2
			c += 2 * (i * (i - 1) // 2)
		else:
			j = i // 2
			i = i - j
			c += i * (i - 1) // 2 + j * (j - 1) // 2
print(c)


T = int(input())
d = dict()
for i in range(26):
	d[chr(97 + i)] = 0
for _ in range(T):
	s = input()
	d[s[0]] += 1
s = 0
for i in range(26):
	if d[chr(97 + i)] == 0:
		continue
	a = (d[chr(i + 97)] + 1) // 2
	b = d[chr(i + 97)] // 2
	s += ((a - 1) * a + b * (b - 1)) // 2
print(s)


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a[0])
s = set(l)
c = []
for i in s:
	c.append(l.count(i))
p = []
q = []
for i in range(len(c)):
	p.append(c[i] // 2)
	q.append(c[i] // 2 + c[i] % 2)
ans = 0
for i in range(len(p)):
	if p[i] >= 2:
		ans += p[i] * (p[i] - 1) // 2
	if q[i] >= 2:
		ans += q[i] * (q[i] - 1) // 2
print(ans)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
letras = {}
for j in range(0, n):
	name = input()
	letra = name[0]
	if letra in letras:
		letras[letra] = letras[letra] + 1
	else:
		letras[letra] = 1
pares = 0
for l in letras:
	direita = int(letras[l] / 2)
	esquerda = letras[l] - direita
	if direita >= 2 and esquerda >= 2:
		pares = pares + ncr(esquerda, 2) + ncr(direita, 2)
	if direita >= 2 and esquerda == 1:
		pares = pares + ncr(direita, 2)
	if direita == 1 and esquerda >= 2:
		pares = pares + ncr(esquerda, 2)
print(int(pares))


n = int(input())
l = []
for _ in range(n):
	l.append(input())
l.sort()
l1 = []
l2 = []
for i in range(0, n - 1, 2):
	l1.append(l[i])
	l2.append(l[i + 1])
if n % 2 == 1:
	l1.append(l[n - 1])
c1 = 0
c2 = 0
for i in range(len(l1)):
	for j in range(i + 1, len(l1)):
		if l1[i][0] == l1[j][0]:
			c1 += 1
for i in range(len(l2)):
	for j in range(i + 1, len(l2)):
		if l2[i][0] == l2[j][0]:
			c2 += 1
print(c1 + c2)


n = int(input())
l = [0] * 1000
for i in range(n):
	s = input()
	l[ord(s[0])] += 1
wyn = 0
for i in range(1000):
	if l[i] % 2 == 0:
		wyn += l[i] // 2 * (l[i] // 2 - 1)
	else:
		wyn += l[i] // 2 * (l[i] // 2 - 1) // 2
		wyn += (l[i] + 1) // 2 * ((l[i] + 1) // 2 - 1) // 2
print(wyn)


class Classroom:

	def __init__(self):
		self.initials = {}

	def hasStudent(self, student):
		return student[0] in self.initials

	def addStudent(self, student):
		if student[0] in self.initials:
			self.initials[student[0]] += 1
		else:
			self.initials[student[0]] = 1

def fatorial(n):
	p = 1
	while n > 1:
		p = p * n
		n -= 1
	return p

def possiblePairs(n):
	return fatorial(n) / (fatorial(2) * fatorial(n - 2))

def main():
	n = int(input())
	students = []
	for i in range(n):
		students.append(input())
	students.sort()
	roomA = Classroom()
	roomB = Classroom()
	lastRoom = 0
	for s in students:
		if lastRoom != 1:
			roomA.addStudent(s)
			lastRoom = 1
		else:
			roomB.addStudent(s)
			lastRoom = 2
	sum = 0
	for k in roomA.initials:
		if roomA.initials[k] > 1:
			sum += possiblePairs(roomA.initials[k])
	for k in roomB.initials:
		if roomB.initials[k] > 1:
			sum += possiblePairs(roomB.initials[k])
	print(int(sum))
main()


n = int(input())
my_dic = {}
x = 0
for i in range(0, 26):
	my_dic[i] = 0
for i in range(0, n):
	name = input()
	charInt = ord(name[0]) - 97
	my_dic[charInt] = my_dic[charInt] + 1
for i in range(0, 26):
	a = my_dic[i] // 2
	b = my_dic[i] - a
	x += a * (a - 1) / 2 + b * (b - 1) / 2
print(int(x))


def main():
	n = int(input())
	fl = {}
	for i in range(n):
		name = input().rstrip()
		if name[0] in fl.keys():
			fl[name[0]] += 1
		else:
			fl[name[0]] = 1
	ans = 0
	for x in fl.keys():
		if fl[x] > 1:
			a = fl[x] // 2
			b = fl[x] - a
			ans += (a * (a - 1) + b * (b - 1)) // 2
	print(ans)
main()


n = int(input())
a = [0] * 26
for i in range(n):
	t = input()
	a[ord(t[0]) - 97] += 1
s = 0
for i in a:
	t1 = i // 2
	t2 = i - t1
	s += t1 * (t1 - 1) // 2 + t2 * (t2 - 1) // 2
print(s)


import math
n = int(input())
c = []
res = []
result = 0
for i in range(n):
	s = input()
	c.append(s[0])
setc = set(c)
for i in setc:
	if c.count(i) > 1:
		res.append(c.count(i))
for i in res:
	r1 = math.ceil(i / 2)
	r2 = i - r1
	r1 = r1 * (r1 - 1) / 2
	r2 = r2 * (r2 - 1) / 2
	result += r1 + r2
print(int(result))


n = int(input())
l = []
for x in range(n):
	k = input()
	l.append(k[0:1])
s = set(l)
sum = 0
for x in s:
	p = l.count(x)
	a = p // 2
	b = p - p // 2
	sum = sum + a * (a - 1) // 2 + b * (b - 1) // 2
print(sum)


from collections import Counter
l = list()
for _ in range(int(input())):
	l.append(input()[0])
c = Counter(l)
cnt = 0
for (item, i_cnt) in c.most_common():
	if i_cnt >= 3:
		p1 = i_cnt // 2
		p2 = i_cnt - p1
		cnt += p1 * (p1 - 1) // 2
		cnt += p2 * (p2 - 1) // 2
print(cnt)


Ar = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = int(input())
ar = []
for _ in range(t):
	a = input()
	ar.append(a[0])
cnt = 0
for i in range(26):
	p = ar.count(Ar[i])
	if p % 2 == 0:
		l = p // 2
		pairs = l * (l - 1)
		cnt += pairs
	else:
		l1 = p // 2
		l2 = p - l1
		pairs1 = l1 * (l1 - 1) // 2
		pairs2 = l2 * (l2 - 1) // 2
		cnt += pairs1 + pairs2
print(cnt)


n = int(input())
a = {}
b = {}
for i in range(n):
	s = input()
	s = s[0]
	if s not in a:
		a[s] = 1
	elif s not in b:
		b[s] = 1
	elif a[s] < b[s]:
		a[s] += 1
	else:
		b[s] += 1
ans = 0
for i in a:
	if a[i] != 1:
		n = a[i]
		ans += n * (n - 1) / 2
for i in b:
	if b[i] != 1:
		n = b[i]
		ans += n * (n - 1) / 2
print(int(ans))


t = int(input())
li = []
while t > 0:
	t = t - 1
	n = input()
	li.append(n[0])
li.sort()
k = 0
j = list(set(li))
for i in j:
	m = li.count(i) // 2
	o = li.count(i) - m
	if m == 2:
		k += 1
	if o == 2:
		k += 1
	if m > 2:
		m = m - 1
		k += m * (m + 1) // 2
	if o > 2:
		o = o - 1
		k += o * (o + 1) // 2
print(k)


from itertools import combinations
import math
n = int(input())
dic = {}
for i in range(n):
	a = input()
	ss = a[0]
	if ss not in dic:
		dic[ss] = 1
	else:
		dic[ss] += 1
ans = 0
for i in dic:
	if dic[i] <= 2:
		continue
	a = math.ceil(dic[i] / 2)
	b = math.floor(dic[i] / 2)
	if dic[i] == 3:
		ans += math.factorial(a) // (math.factorial(2) * math.factorial(a - 2))
		continue
	ans += math.factorial(a) // (math.factorial(2) * math.factorial(a - 2))
	ans += math.factorial(b) // (math.factorial(2) * math.factorial(b - 2))
print(ans)


from collections import Counter
c = Counter()
n = int(input())
for _ in range(n):
	s = input()
	c[s[0]] += 1

def cn(x):
	return x * (x - 1) // 2
r = 0
for v in c.values():
	x = v // 2
	r += cn(x)
	r += cn(v - x)
print(r)


a = [0] * 26
for i in range(int(input())):
	a[ord(input()[0]) - 97] += 1
print(sum((v * v - v - v // 2 * (v - v // 2) * 2 for v in a)) // 2)


from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n):
	d[input()[0]] += 1
ans = 0
for v in d.values():
	t = v // 2
	if v % 2:
		ans += t ** 2
	else:
		ans += t * (t - 1)
print(ans)


import math

def foo(n, r):
	if n - r < 0:
		return math.factorial(n) / (math.factorial(r) * 1)
	return math.factorial(n) / (math.factorial(r) * math.factorial(n - r))
l = [0] * 30
t = int(input())
for i in range(0, t):
	n = input()
	l[ord(n[0]) - ord('a')] += 1
m = max(l)
m1 = l.count(m)
sum = 0
for j in l:
	if j != 0:
		m = j
		m2 = m // 2
		m3 = m - m2
		if m2 >= 2:
			ans1 = int(foo(m2, 2))
		else:
			ans1 = 0
		if m3 >= 2:
			ans2 = int(foo(m3, 2))
		else:
			ans2 = 0
		sum = sum + ans1 + ans2
print(sum)


n = int(input())
lst = []
for _ in range(n):
	lst.append(input())
letterDict = {}
for i in lst:
	if i[0] in letterDict.keys():
		letterDict[i[0]] += 1
	else:
		letterDict[i[0]] = 1
pairs = 0
for i in letterDict.values():
	firstClass = i // 2
	secondClass = i - i // 2
	pairs += firstClass * (firstClass - 1) // 2 + secondClass * (secondClass - 1) // 2
print(pairs)


import operator as op
from functools import reduce
ncrr = {}

def ncr(n, r):
	if n < r:
		return 0
	global ncrr
	try:
		return ncrr[n, r]
	except:
		r = min(r, n - r)
		numer = reduce(op.mul, range(n, n - r, -1), 1)
		denom = reduce(op.mul, range(1, r + 1), 1)
		ncrr[n, r] = numer / denom
		return ncrr[n, r]
import math

def bar(n):
	if n <= 2:
		return 0
	if n % 2 == 0:
		return 2 * ncr(int(n / 2), 2)
	else:
		n_ = math.ceil(n / 2)
		n__ = math.floor(n / 2)
		return ncr(n_, 2) + ncr(n__, 2)

def foo(d):
	summ = 0
	for val in d.values():
		summ += bar(val)
	return int(summ)
t = int(input())
d = {}
for _ in range(t):
	name = input()
	d[name[0]] = d.get(name[0], 0) + 1
print(foo(d))


def calc(n):
	return n * (n - 1) >> 1
students = []
n = int(input())
for i in range(n):
	temp = input()
	students.append(temp[0])
students = sorted(students)
alphabetsCount = [students.count(i) for i in list(set(students))]
count = 0
for i in alphabetsCount:
	if i > 2:
		firstClassMembers = i // 2
		secondClassMembers = i - firstClassMembers
		count += calc(firstClassMembers) + calc(secondClassMembers)
print(count)


import math
n = int(input())
data = [input()[0] for _ in range(n)]
data.sort()
prev = 0
sum = 0

def foo(count):
	global sum
	if count % 2 == 0:
		sum += count * count // 4 - count // 2
	else:
		x = count // 2
		y = count - x
		sum += x * (x - 1) // 2
		sum += y * (y - 1) // 2
for i in range(1, n):
	if data[prev] == data[i]:
		continue
	foo(i - prev)
	prev = i
foo(n - prev)
print(sum)


from collections import defaultdict
import math

def ncr(x):
	return x * (x - 1) // 2
x = int(input())
count = defaultdict(lambda : 0)
for i in range(x):
	a = input()
	count[a[0]] += 1
ans = 0
for i in count.keys():
	ans += ncr(count[i] // 2)
	ans += ncr(count[i] - count[i] // 2)
print(ans)


a = int(input())
m = []
s = set()
d = dict()
r = 0
for i in range(a):
	m.append(input())
for i in m:
	if i[0] not in s:
		s.add(i[0])
		d[i[0]] = 1
	else:
		d[i[0]] += 1
m = d.keys()
s = 0
t = 0
h = 0
rh = 0
for i in m:
	s = int(d[i])
	t = s / 2
	if t % 1 != 0:
		h = s // 2 + 1
	else:
		h = s // 2
	if h >= 2:
		for j in range(1, h):
			rh += j
		r += rh
		rh = 0
		for j in range(1, s - h):
			rh += j
		r += rh
		rh = 0
print(r)


a = input()
class_A = {}
class_B = {}
for _ in range(int(a)):
	letter = input()[0]
	if class_A.get(letter, 0) <= class_B.get(letter, 0):
		class_A[letter] = class_A.get(letter, 0) + 1
	else:
		class_B[letter] = class_B.get(letter, 0) + 1

def p(n):
	if n == 1:
		return 0
	return p(n - 1) + (n - 1)
print(sum((p(n) for n in class_A.values())) + sum((p(n) for n in class_B.values())))


from sys import stdin
n = int(stdin.readline())
d = {}
for i in range(n):
	s = stdin.readline().strip()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
count = 0
for ele in d:
	if d[ele] == 1:
		pass
	else:
		a = d[ele] // 2
		b = d[ele] - a
		count += a * (a - 1) // 2 + b * (b - 1) // 2
print(count)


from collections import defaultdict
f = lambda x: x * (x - 1) // 2
d = defaultdict(int)
for _ in range(int(input())):
	d[input()[0]] += 1
print(sum((f(x // 2) + f(x - x // 2) for x in d.values() if x > 2)))


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
msi = lambda : map(int, stdin.readline().split())
lsi = lambda : list(msi())
n = ii()
A = [0] * 26
for _ in range(n):
	s = si()
	A[ord(s[0]) - ord('a')] += 1
x = 0
for a in A:
	if a:
		n1 = a // 2
		n2 = a - n1
		x += n1 * (n1 - 1) // 2
		x += n2 * (n2 - 1) // 2
print(x)


x = int(input())
m = {}
res = 0

def c(n):
	if n > 0:
		return n * (n - 1) // 2
	else:
		return 0
for i in range(x):
	k = input()[0]
	if k not in m:
		m[k] = 1
	else:
		m[k] = m[k] + 1
for i in m:
	a = m[i] // 2
	b = m[i] - a
	res += c(a) + c(b)
print(res)


n = int(input())
D = {}
for _ in range(n):
	x = input()[:1]
	if x in D:
		D[x] += 1
	else:
		D[x] = 1
T = 0
for i in D:
	m = 10000000
	for j in range(D[i]):
		m = min(m, j * (j - 1) // 2 + (D[i] - j) * (D[i] - j - 1) // 2)
	T += m
print(T)


from math import factorial as f

def c(n):
	return f(n) / (f(2) * f(n - 2))
n = int(input())
l = dict()
for i in range(n):
	x = input()[0]
	if x not in l:
		l[x] = 1
	else:
		l[x] += 1
count = 0
d = []
for i in l:
	if l[i] > 2:
		if l[i] % 2 == 0:
			d.append(l[i] // 2)
			d.append(l[i] // 2)
		else:
			d.append(l[i] // 2)
			d.append(l[i] // 2 + 1)
for i in d:
	if i == 2:
		count += 1
	elif i > 2:
		count += c(i)
print(int(count))


from collections import Counter as c
l = [input()[0] for i in range(int(input()))]
k = [(i[1] // 2 + 1, i[1] // 2) if i[1] % 2 else (i[1] // 2, i[1] // 2) for i in c(l).items()]
print(sum([i[0] * (i[0] - 1) // 2 + i[1] * (i[1] - 1) // 2 for i in k]))


def calculateTakingScore(n):
	if n <= 2:
		return 0
	elif n % 2 == 0:
		return n / 2 * (n / 2 - 1)
	else:
		return (n - 1) / 2 * ((n - 1) / 2 - 1) / 2 + (n + 1) / 2 * ((n + 1) / 2 - 1) / 2
t = int(input())
d = {}
while t > 0:
	t -= 1
	s = input()
	firstChar = s[0]
	if firstChar in d:
		d[firstChar] += 1
	else:
		d[firstChar] = 1
sun = 0
for (_, key) in enumerate(d):
	temp = calculateTakingScore(d[key])
	sun += temp
print(int(sun))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
di = {}
for i in range(n):
	s = stringIn()
	if s[0] not in di:
		di[s[0]] = 1
	else:
		di[s[0]] += 1
total = 0
for ele in di:
	m = di[ele]
	a1 = m // 2
	a2 = m - a1
	t1 = a1 * (a1 - 1) // 2
	t2 = a2 * (a2 - 1) // 2
	total += t1 + t2
print(total)


n = int(input())
a = []
f = []
s = []
for i in range(n):
	x = input()
	a.append(x[0])
for i in a:
	if i not in f:
		f.append(i)
	elif i not in s:
		s.append(i)
	elif i in f and f.count(i) > s.count(i):
		s.append(i)
	elif i in f and f.count(i) >= s.count(i):
		f.append(i)
was1 = []
was2 = []
c = 0
for i in f:
	cou = 0
	if i not in was1 and f.count(i) > 1:
		for j in range(1, f.count(i)):
			cou += j
	was1.append(i)
	c += cou
for i in s:
	cou = 0
	if i not in was2 and s.count(i) > 1:
		for j in range(1, s.count(i)):
			cou += j
	was2.append(i)
	c += cou
print(c)


from math import *
from collections import *
n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s[0])
l = Counter(l)
ans = 0
for i in l.values():
	x = i // 2
	y = i - x
	ans += x * (x - 1) // 2 + y * (y - 1) // 2
print(ans)


n = int(input())
alpha = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()
d = {}
for char in alpha:
	d[char] = 0
for loop in range(0, n):
	name = input()
	d[name[0]] = d[name[0]] + 1
count = 0
for char in alpha:
	li = [d[char] // 2, d[char] - d[char] // 2]
	for ele in li:
		if ele > 1:
			count += ele * (ele - 1) // 2
print(count)


n = int(input())
chars = [input()[0] for _ in range(n)]
d = {}
for c in chars:
	d.setdefault(c, 0)
	d[c] += 1
ret = 0
for v in d.values():
	if v > 1:
		left = v // 2
		right = v - left
		ret += left * (left - 1) // 2 + right * (right - 1) // 2
print(ret)


n = int(input())
d = {}
for _ in range(n):
	s = input()
	ss = s[0]
	if ss not in d:
		d[ss] = 0
	d[ss] += 1
ans = 0
for k in d:
	c = d[k]
	cc = c // 2 + c % 2
	ans += cc * (cc - 1) // 2
	cc = c // 2
	ans += cc * (cc - 1) // 2
print(ans)


from collections import Counter
n = int(input())
chatty_pairs = 0
students = []
for _ in range(n):
	students.append(input()[0])
s = Counter(students)
for i in s.values():
	if i <= 2:
		pass
	else:
		k = i // 2
		if i % 2 == 0:
			chatty_pairs += k * (k - 1)
		else:
			chatty_pairs += k * k
print(chatty_pairs)


from collections import Counter
n = int(input())
l = Counter([input()[0] for _ in range(n)])
ans = 0
C2 = lambda x: (x ** 2 - x) // 2 if x > 0 else 0
for i in l:
	ans += C2(l[i] // 2) * 2 if not l[i] % 2 else C2(l[i] // 2) + C2(l[i] // 2 + 1)
print(ans)


def main():
	n = int(input())
	dic = {}
	ans = 0
	for i in range(n):
		s = input()
		if s[0] in dic:
			dic[s[0]] += 1
		else:
			dic[s[0]] = 1
	for (x, y) in dic.items():
		if y > 1:
			first = y // 2
			second = y - first
			ans += first * (first - 1) // 2 + second * (second - 1) // 2
	print(ans)
main()


from math import factorial as f

def c(a, b):
	return int(f(a) / f(b) / f(a - b))
n = int(input())
A = []
for _ in range(n):
	A.append(input())
L = set([x[0] for x in A])
B = [[x for x in A if x[0] == y] for y in L]
t = 0
for l in B:
	a = len(l) // 2
	b = len(l) - a
	if a >= 2:
		t += c(a, 2)
	if b >= 2:
		t += c(b, 2)
print(t)


n = int(input())
arr = [input()[0] for i in range(n)]
result = 0
for i in set(arr):
	c = arr.count(i)
	if c % 2 == 0:
		(l, r) = (c // 2, c // 2)
	else:
		(l, r) = (c // 2, c // 2 + 1)
	result += l * (l - 1) // 2
	result += r * (r - 1) // 2
print(result)


n = int(input())
a = [0 for i in range(26)]
for i in range(n):
	tmp = input()
	tmp = tmp[0]
	a[ord(tmp) - 97] = a[ord(tmp) - 97] + 1

def solver(a):
	if a % 2 == 0:
		b = a / 2
		return b * (b - 1)
	else:
		b = int(a / 2)
		c = a - b
		return b * (b - 1) / 2 + c * (c - 1) / 2
sum = 0
for i in range(26):
	if a[i] != 0:
		sum = sum + solver(a[i])
print(int(sum))


n = int(input())
names = {}
q = [i * (i - 1) // 2 for i in range(100)]
for i in range(n):
	k = input()[0]
	if k not in names:
		names[k] = 1
	else:
		names[k] += 1
ans = 0
for (name, val) in names.items():
	if val > 2:
		ans += q[val // 2] + q[val // 2 + val % 2]
print(ans)


import math

def co(a):
	return int(a * (a - 1) / 2)

def silent(A):
	T1 = [0 for i in range(26)]
	T2 = [0 for i in range(26)]
	num = 0
	for i in A:
		temp = min(T1[ord(i[0]) - 97], T2[ord(i[0]) - 97])
		if temp == T1[ord(i[0]) - 97]:
			T1[ord(i[0]) - 97] += 1
		else:
			T2[ord(i[0]) - 97] += 1
	for i in range(26):
		if T1[i] >= 2:
			num += co(T1[i])
	for i in range(26):
		if T2[i] >= 2:
			num += co(T2[i])
	return num
n = int(input())
A = []
for i in range(n):
	A.append(input())
print(silent(A))


entrada = int(input())
result = 0
arr = [0] * 26
for i in range(entrada):
	texto = list(input())
	arr[ord(texto[0]) - 97] += 1
for i in range(26):
	val1 = arr[i] // 2
	val2 = arr[i] - val1
	result += val1 * (val1 - 1) // 2
	result += val2 * (val2 - 1) // 2
print(result)


from collections import Counter
n = int(input())
c = []
for _ in range(n):
	c.append(input()[0])
c = Counter(c)
x = 0
for i in c.keys():
	a = c[i] // 2 * (c[i] // 2 - 1) // 2
	b = (c[i] // 2 + c[i] % 2) * (c[i] // 2 + c[i] % 2 - 1) // 2
	x += a + b
print(x)


n = int(input())
dic = {}
for _ in range(n):
	name = input()
	if not name[0] in dic:
		dic[name[0]] = 1
	else:
		dic[name[0]] += 1
result = 0
for d in dic:
	if dic[d] % 2 == 0:
		result += dic[d] // 2 * (dic[d] // 2 - 1)
	else:
		result += dic[d] // 2 * (dic[d] // 2 - 1) // 2 + (dic[d] // 2 + 1) * (dic[d] // 2) // 2
print(result)


import itertools
T = int(input())
n = []
for i in range(T):
	n.append(str(input()))
u = []
p = 0
for i in range(len(n)):
	d = []
	k = n[i][0]
	if k not in u:
		for j in range(len(n)):
			if n[j][0] == k:
				d.append(n[j])
	u.append(k)
	p += len(list(itertools.combinations(d[:int(len(d) / 2)], 2))) + len(list(itertools.combinations(d[int(len(d) / 2):], 2)))
print(p)


import math as ma
n = int(input())
l = []
for i in range(n):
	x = str(input())
	l.append(x[0])
l2 = set(l)
l2 = list(l2)
ans = 0
for i in range(len(l2)):
	x = l.count(l2[i])
	x1 = x // 2
	x2 = ma.ceil(x / 2)
	ans = ans + x1 * (x1 - 1) // 2 + x2 * (x2 - 1) // 2
print(ans)


l = [0] * 26
for _ in range(int(input())):
	s = input()
	x = s[0]
	l[ord(x) - 97] += 1
ans = 0
for i in l:
	if i > 1:
		x1 = i // 2
		x2 = i - x1
		ans += x1 * (x1 + 1) // 2 - x1
		ans += x2 * (x2 + 1) // 2 - x2
print(ans)


import sys
import math
import collections
from pprint import pprint as pp
mod = 1000000007
MAX = 10 ** 10

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
n = int(input())
a = {}
for i in range(n):
	s = input()
	if s[0] in a:
		a[s[0]] += 1
	else:
		a[s[0]] = 1
ans = 0
for i in a:
	if a[i] > 2:
		x = y = a[i] // 2
		if a[i] % 2 == 1:
			x += 1
		ans += x * (x - 1) // 2 + y * (y - 1) // 2
print(ans)


def sochet(n, m):
	nf = 1
	for i in range(1, n + 1):
		nf *= i
	mf = 1
	for i in range(1, m + 1):
		mf *= i
	nminmf = 1
	for i in range(1, n - m + 1):
		nminmf *= i
	return nf // (mf * nminmf)
n = int(input())
A = [0] * 30
cnt = 0
for i in range(n):
	s = input()
	A[ord(s[0]) - ord('a')] += 1
for i in range(30):
	cnt += sochet(A[i] // 2, 2) + sochet(A[i] - A[i] // 2, 2)
print(cnt)


def choose(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0
d = {}
n = int(input())
for i in range(n):
	tmp = input()
	if tmp[0] not in d.keys():
		d[tmp[0]] = 1
	else:
		d[tmp[0]] += 1
Pairs = 0
for M in d.values():
	if not M % 2:
		Pairs += 2 * choose(M // 2, 2)
	else:
		Pairs += choose((M + 1) // 2, 2) + choose((M - 1) // 2, 2)
print(Pairs)


n = int(input())
l = []
S = 0
for i in range(0, n):
	s = input().rstrip()
	x = list(s)
	l.append(x[0])
for i in range(97, 123):
	g = chr(i)
	if g in l and l.count(g) % 2 == 0:
		if l.count(g) == 2:
			continue
		elif l.count(g) == 4:
			S += 2
		else:
			T = l.count(g) // 2 - 1
			R = T * (T + 1) // 2
			S = S + R
			S += R
	elif g in l and l.count(g) % 2 != 0:
		if l.count(g) == 3:
			S = S + 1
		else:
			A = l.count(g) // 2 - 1
			B = l.count(g) - (A + 1) - 1
			C = A * (A + 1) // 2
			D = B * (B + 1) // 2
			S += C
			S += D
print(S)


n = int(input())
(sl, a, b) = ([], [], [])
for i in range(n):
	sl.append(input()[0])
sl.sort()
for i in range(n):
	if i % 2 == 0:
		a.append(sl[i])
	else:
		b.append(sl[i])
(ac, bc) = (0, 0)
for i in list('abcdefghijklmnopqrstuvwxyz'):
	aa = a.count(i)
	bb = b.count(i)
	if aa >= 2:
		ac += aa * (aa - 1) / 2
	if bb >= 2:
		bc += bb * (bb - 1) / 2
print(int(ac + bc))


import math
letters = [0 for _ in range(26)]

def h(n):
	if n < 2:
		return 0
	return math.factorial(n) / (2 * math.factorial(n - 2))
n = int(input())
for i in range(n):
	s = input()
	letters[ord(s[0]) - 97] += 1
ch1 = 0
ch2 = 0
for e in letters:
	if e > 2:
		a = e
		a -= e // 2
		ch1 += h(e // 2)
		ch2 += h(a)
print(int(ch1 + ch2))


import math
s = list('abcdefghijklmnopqrstuvwxyz')
l = [0] * 26
for _ in range(int(input())):
	s = input()
	l[ord(s[0]) - ord('a')] += 1
f = 0
for i in l:
	if i == 3:
		f += 1
	if i > 3:
		if i % 2 != 0:
			(n, n1) = (i // 2, i // 2 + 1)
			f += math.factorial(n) // (math.factorial(n - 2) * 2)
			f += math.factorial(n1) // (math.factorial(n1 - 2) * 2)
		else:
			n = i // 2
			f += 2 * (math.factorial(n) // (math.factorial(n - 2) * 2))
print(f)


def fac(n):
	fact = 1
	for i in range(n, 0, -1):
		fact *= i
	return fact
n = int(input())
d = {}
for _ in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
ans = 0
z = 0
y = 0
for i in d.items():
	if i[1] % 2 == 0:
		no = i[1] // 2
		z = 2 * (fac(no) // (fac(2) * fac(no - 2)))
		ans += z
	else:
		a1 = i[1] // 2
		a2 = i[1] // 2 + 1
		z = fac(a1) // (fac(2) * fac(a1 - 2))
		y = fac(a2) // (fac(2) * fac(a2 - 2))
		ans += z + y
print(ans)


from sys import stdin
import math
from collections import defaultdict, deque
import bisect

def nc2(x):
	return x * (x - 1) // 2
I = stdin.readline
n = int(I())
arr = [0 for i in range(26)]
for _ in range(n):
	s = I().rstrip()
	arr[ord(s[0]) - ord('a')] += 1
ans = 0
for i in arr:
	x = i // 2
	y = i - x
	ans += nc2(x)
	ans += nc2(y)
print(ans)


N = int(input())
list = []

def function(Integer):
	if Integer % 2 == 0:
		return Integer / 2 * (Integer / 2 - 1)
	else:
		a = (Integer + 1) / 2
		return a * (a - 1) / 2 + (a - 1) * (a - 2) / 2
list = [0] * 26
for i in range(N):
	s = input()
	list[ord(s[0]) - 97] += 1
count = 0
for i in list:
	count += function(i)
print(int(count))


from math import factorial
n = int(input())
l = []
for i in range(n):
	st = input()
	l.append(st[0])

def fact(j):
	if j == 1:
		return 0
	else:
		return factorial(j) // (factorial(j - 2) * 2)
se = set(l)
total = 0
for i in se:
	co = l.count(i)
	if co > 1:
		if co % 2 == 0:
			c1 = co // 2
			total += fact(c1) * 2
		else:
			c2 = co // 2
			c3 = (co + 1) // 2
			total += fact(c2)
			total += fact(c3)
print(total)


from collections import defaultdict
count_chatty = lambda n: n * (n - 1) // 2

def solve():
	n = int(input())
	first_letters = defaultdict(int)
	for i in range(n):
		name = input()
		first_letters[name[0]] += 1
	chatty = 0
	for pair in first_letters.items():
		chatty_half = count_chatty(pair[1] // 2)
		chatty += 2 * chatty_half
		if pair[1] % 2 == 1:
			chatty += pair[1] // 2
	return chatty
print(solve())


n = int(input())
ls = [0 for i in range(26)]
for i in range(n):
	name = input()
	ls[ord(name[0]) - 97] += 1
count = 0
for i in range(26):
	if ls[i] > 2:
		if ls[i] % 2 == 0:
			count += ls[i] // 2 * (ls[i] // 2 - 1)
		else:
			count += ls[i] // 2 * (ls[i] // 2 - 1) // 2 + (ls[i] + 1) // 2 * ((ls[i] + 1) // 2 - 1) // 2
print(count)


def fact(n):
	f = 1
	for i in range(1, n + 1):
		f = f * i
	return int(f)

def ncr(n):
	if n < 2:
		return 0
	return int(fact(n) / (fact(2) * fact(n - 2)))

def pair(n):
	x = int(n / 2)
	y = x - n
	res = ncr(x) + ncr(y)
	return res
n = int(input())
l = []
for i in range(n):
	l.append(str(input()))
char = []
for i in l:
	char.append(i[0])
r = 0
s = []
for i in char:
	if i not in s:
		s.append(i)
for i in range(len(s)):
	c = 0
	x = 0
	y = 0
	for j in range(len(char)):
		if s[i] == char[j]:
			c += 1
	x = int(c / 2)
	y = c - x
	r = r + ncr(x) + ncr(y)
print(r)


def minChattingGroups(names):
	count = [0] * 26
	for i in names:
		count[ord(i[0]) - 97] += 1
	res = 0
	for i in count:
		(a, b) = (None, None)
		if i % 2 == 0:
			(a, b) = (i // 2, i // 2)
		else:
			(a, b) = (i // 2, i // 2 + 1)
		res += a * (a - 1) // 2 + b * (b - 1) // 2
	return res
n = int(input())
names = []
for _ in range(n):
	names.append(input())
print(minChattingGroups(names))


n = int(input())
a = []
for _ in range(n):
	a.append(input()[:1])
s = set(a)
if len(s) == n:
	print('0')
else:
	b = []
	for i in s:
		c = a.count(i)
		if c > 1:
			b.append(c)
	n = 0
	for i in b:
		m = 1
		if i % 2 != 0:
			for j in reversed(range(i // 2, i // 2 + 2)):
				m *= j
			m //= 2
			n += m
			m = 1
			for j in reversed(range(i // 2 - 1, i // 2 + 1)):
				m *= j
			m //= 2
			n += m
			m = 1
		else:
			for j in reversed(range(i // 2 - 1, i // 2 + 1)):
				m *= j
			m //= 2
			n += m
			n += m
	print(n)


n = int(input())
a = []
d = []
c = 0
for i in range(n):
	s = input()
	d.append(s[0])
f = list(set(d))
for i in range(len(f)):
	a.append(d.count(f[i]))
for i in range(len(a)):
	if a[i] > 1:
		l = d.count(a[i])
		if a[i] % 2 == 0:
			c = c + int(a[i] / 2) * (int(a[i] / 2) - 1)
		else:
			c = c + int(a[i] / 2) * (int(a[i] / 2) - 1) / 2 + int(a[i] / 2) * (int(a[i] / 2) + 1) / 2
print(int(c))


n = int(input())
l = []
for i in range(n):
	l.append(ord(input()[0]))
l.sort()
q = []
q1 = []
for i in range(len(l)):
	if i % 2 == 0:
		q.append(l[i])
	else:
		q1.append(l[i])
x = 0
if len(q) > 0:
	t = q[0]
	c = 0
	for i in range(len(q)):
		if t == q[i]:
			c = c + 1
		else:
			x = x + int(c * (c - 1) / 2)
			t = q[i]
			c = 1
if i == len(q) - 1:
	x = x + int(c * (c - 1) / 2)
if len(q1) > 0:
	t = q1[0]
	c = 0
	for i in range(len(q1)):
		if t == q1[i]:
			c = c + 1
		else:
			x = x + int(c * (c - 1) / 2)
			t = q1[i]
			c = 1
if i == len(q1) - 1:
	x = x + int(c * (c - 1) / 2)
print(x)


a = [0] * 26
for _ in [0] * int(input()):
	a[ord(input()[0]) - 97] += 1
print(sum(((v // 2) ** 2 + (v - v // 2) ** 2 - v for v in a)) // 2)


n = int(input())
d = {}
for i in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
ans = 0
for s in d:
	kol = d[s] // 2
	kol1 = d[s] - kol
	ans += (kol - 1) * kol / 2 + (kol1 - 1) * kol1 / 2
print(int(ans))


import math
n = int(input())
l = list()
for i in range(n):
	s = input()
	l.append(s)
l.sort()
l1 = list()
l2 = list()
for i in range(n):
	if i % 2 == 0:
		l1.append(l[i])
	else:
		l2.append(l[i])
d1 = dict()
d2 = dict()
for i in range(len(l1)):
	if l1[i][0] not in d1.keys():
		d1[l1[i][0]] = 1
	else:
		d1[l1[i][0]] += 1
for i in range(len(l2)):
	if l2[i][0] not in d2.keys():
		d2[l2[i][0]] = 1
	else:
		d2[l2[i][0]] += 1
ans = 0
for v in d1.values():
	if v > 1:
		combinatoria = math.factorial(v) // (math.factorial(v - 2) * 2)
		ans += combinatoria
for v in d2.values():
	if v > 1:
		combinatoria = math.factorial(v) // (math.factorial(v - 2) * 2)
		ans += combinatoria
print(ans)


n = int(input(''))
D = {}
su = 0
for i in range(n):
	z = input('')[0]
	if z in D:
		D[z] += 1
	else:
		D[z] = 1
for po in D:
	k = D[po] // 2
	su += k * (k - 1) // 2 + (D[po] - k) * (D[po] - k - 1) // 2
print(su)


from collections import Counter
import math

def nCr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
n = int(input())
l = []
for i in range(n):
	l.append(input()[0])
c = Counter(l).most_common()
p = q = 0
for (i, j) in c:
	if j != 1:
		x = j // 2
		y = j - x
		if x > 1:
			p += nCr(x, 2)
		if y > 1:
			q += nCr(y, 2)
print(int(p + q))


fact = [0] * 101
fact[1] = 1
for i in range(2, 101):
	fact[i] = fact[i - 1] * i

def nCr(n, r):
	if n == r:
		return 1
	return fact[n] // (fact[r] * fact[n - r])

def main():
	n = int(input())
	arr = [0] * n
	for i in range(n):
		arr[i] = input()[:1]
	from collections import Counter
	d = Counter(arr)
	ans = 0
	for i in d:
		if d[i] <= 2:
			continue
		x = d[i] // 2
		if d[i] % 2 == 1:
			ans += nCr(x + 1, 2)
			ans += nCr(x, 2)
		else:
			ans += 2 * nCr(x, 2)
	print(ans)
main()


import io
import os
from collections import defaultdict
from sys import stdin, stdout
from math import gcd

def main():
	n = int(input())
	num = [0] * 26
	for _ in range(n):
		name = input()
		num[ord(name[0]) - ord('a')] += 1
	res = 0
	for i in range(26):
		a = (num[i] + 1) // 2
		b = num[i] - a
		res += a * (a - 1) // 2
		res += b * (b - 1) // 2
	print(res)
main()


from sys import stdin
from collections import defaultdict

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
d = defaultdict(int)
for _ in range(n):
	d[input()[0]] += 1
pair = 0
for e in d:
	x = d[e] // 2
	y = d[e] - x
	pair += x * (x - 1) // 2
	pair += y * (y - 1) // 2
print(pair)


from collections import defaultdict
n = int(input())
arr = []
d = defaultdict(int)
for i in range(n):
	arr.append(input())
	d[arr[i][0]] += 1
ans = 0
for i in d:
	x = d[i]
	y = x // 2
	x -= y
	ans += x * (x - 1) // 2
	ans += y * (y - 1) // 2
print(ans)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
else:
	_str = str
	str = lambda x=b'': x if type(x) is bytes else _str(x).encode()

def main():
	n = int(input())
	s = 0
	for i in Counter((input()[0] for _ in range(n))).values():
		s += i // 2 * (i // 2 - 1) // 2 + (i - i // 2) * (i - i // 2 - 1) // 2
	print(s)
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):
		if self.buffer.tell():
			return self.buffer.read()
		return os.read(self._fd, os.fstat(self._fd).st_size)

	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))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', b'\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip(b'\r\n')
main()


from math import ceil
n = int(input().strip())
freq = [0] * 26
for i in range(n):
	s = input().strip()
	freq[ord(s[0]) - ord('a')] += 1
ans = 0
for i in freq:
	a = i // 2
	b = ceil(i / 2)
	ans += a * (a - 1) // 2 + b * (b - 1) // 2
print(ans)


import math

def nCm(n, m):
	return math.factorial(n) // (math.factorial(m) * math.factorial(n - m))
n = int(input())
names = [input() for _ in range(n)]
kinds = {}
for i in names:
	if i[0] in kinds.keys():
		kinds[i[0]] += 1
	else:
		kinds[i[0]] = 1
letters = [i for i in kinds.values() if i > 1]
answer = 0
for i in letters:
	if i % 2 == 0:
		answer += nCm(i // 2, 2) * 2 if i // 2 > 1 else 0
	else:
		answer += nCm((i - 1) // 2, 2) if (i - 1) // 2 > 1 else 0
		answer += nCm((i + 1) // 2, 2)
print(answer)


from math import *
N = int(input())
ls = []
for i in range(N):
	ls.append(input())
d = {}
for i in ls:
	try:
		d[i[0]] += 1
	except:
		d[i[0]] = 1
ls = []
for (k, v) in d.items():
	ls.append(v // 2)
	ls.append(ceil(v / 2))
Sum = 0
for i in ls:
	Sum += i * (i - 1) // 2
print(Sum)


def main():
	arr = [0] * 26
	for i in range(int(input())):
		s = input()
		s = ord(s[0]) - ord('a')
		arr[s] += 1
	ans = 0
	for i in range(26):
		a = arr[i] // 2
		b = arr[i] - a
		ans += a * (a - 1)
		ans += b * (b - 1)
	print(ans >> 1)
	return 0
main()


import math
from collections import defaultdict

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def ncr(n, r):
	return fact(n) / (fact(r) * fact(n - r))
n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x)
d = defaultdict(lambda : 0)
for i in range(n):
	z = a[i][0]
	d[z] += 1
(count_1, count_2) = (0, 0)
j = 0
for (keys, values) in d.items():
	if values < 2:
		continue
	s = values // 2
	rest = values - s
	if j % 2 == 0:
		if s > rest:
			if s > 1:
				count_1 += ncr(s, 2)
			if rest > 1:
				count_2 += ncr(rest, 2)
		else:
			if rest > 1:
				count_1 += ncr(rest, 2)
			if s > 1:
				count_2 += ncr(s, 2)
	elif s > rest:
		if s > 1:
			count_2 += ncr(s, 2)
		if rest > 1:
			count_1 += ncr(rest, 2)
	else:
		if rest > 1:
			count_2 += ncr(rest, 2)
		if s > 1:
			count_1 += ncr(s, 2)
print(int(count_1 + count_2))


from itertools import combinations
from collections import Counter
n = int(input())
lis = []
for i in range(n):
	lis.append(input()[0])
lis.sort()
if n < 2:
	print(0)
	exit()
one = []
two = []
while len(lis) != 0:
	one.append(lis[0])
	del lis[0]
	if len(lis) != 0:
		two.append(lis[0])
		del lis[0]
cone = Counter(one).most_common()
ctwo = Counter(two).most_common()
total1 = 0
total2 = 0
for i in cone:
	if i[1] == 1:
		break
	total1 += len(list(combinations([i[0]] * i[1], 2)))
for i in ctwo:
	if i[1] == 1:
		break
	total2 += len(list(combinations([i[0]] * i[1], 2)))
print(total1 + total2)


n = int(input())
a = [0] * 26
ans = 0
for i in range(n):
	x = input()
	a[ord(x[0]) - ord('a')] += 1
for i in range(26):
	if a[i] > 0:
		k1 = a[i] // 2
		k2 = a[i] - k1
		ans = ans + k1 * (k1 - 1) // 2 + k2 * (k2 - 1) // 2
print(int(ans))


from collections import Counter
class1 = [0] * 26
class2 = [0] * 26
n = int(input())
firsts = []
for _ in range(0, n):
	name = input()
	firsts.append(name[0])
c = Counter(firsts)
firsts = list(set(firsts))
for i in range(0, len(firsts)):
	k = c[firsts[i]] // 2
	class1[ord(firsts[i]) - 97] += k
	class2[ord(firsts[i]) - 97] += c[firsts[i]] - k
sum = 0
for i in class1:
	sum += i * (i - 1) // 2
for i in class2:
	sum += i * (i - 1) // 2
print(sum)


N = int(input())
kiek = [0] * 26
for x in range(N):
	kiek[ord(input()[0]) - ord('a')] += 1
ats = 0
for i in kiek:
	puse = i // 2
	ats += puse * (puse - 1) // 2
	ats += (i - puse) * (i - puse - 1) // 2
print(ats)


n = int(input())
d = [0] * 26
for _ in range(n):
	d[ord(input()[0]) - ord('a')] += 1
t = 0
for i in range(26):
	a = d[i] // 2
	b = d[i] - a
	if a > 1:
		t += a * (a - 1) // 2
	if b > 1:
		t += b * (b - 1) // 2
print(t)


counters = [0 for _ in range(26)]
n = int(input())
for i in range(n):
	name = input()
	c = ord(name[0]) - ord('a')
	counters[c] += 1

def f(p):
	return p * (p - 1) // 2
s = 0
for p in counters:
	s += f(p // 2) + f((p + 1) // 2)
print(s)


from itertools import combinations
no_stu = input()
name = []
letter = []
a = []
b = []
u = 0
for i in range(int(no_stu)):
	name.append(input())
for i in range(int(no_stu)):
	letter.append(name[i][0])
letter = sorted(letter)
for i in range(len(letter)):
	if i % 2 == 0:
		a.append(letter[i])
	else:
		b.append(letter[i])
w = list(combinations(a, 2))
t = list(combinations(b, 2))
for i in w:
	if i[0] == i[1]:
		u += 1
for i in t:
	if i[0] == i[1]:
		u += 1
print(u)


k = int(input())
l = []
n = []
freq = []
c1 = []
c2 = []
sum = 0
for i in range(k):
	a = input().strip()
	if a[0] not in l:
		l.append(a[0])
	n.append(a[0])
for i in l:
	freq.append(n.count(i))
for i in freq:
	c1.append(i // 2)
	c2.append(i - i // 2)
for i in c1:
	if i > 0:
		sum += i * (i - 1) // 2
for i in c2:
	if i > 0:
		sum += i * (i - 1) // 2
print(sum)


def factorial(x):
	if x <= 1:
		return 1
	else:
		return x * factorial(x - 1)

def A():
	n = int(input())
	first_letter_dict = {}
	first_class = []
	second_class = []
	x = 0
	for i in range(n):
		name = input()
		if name[0] in first_letter_dict.keys():
			first_letter_dict[name[0]] += 1
		else:
			first_letter_dict[name[0]] = 1
	nums = [first_letter_dict[k] for k in first_letter_dict.keys()]
	for n in nums:
		if n == 1:
			first_class.append(n)
		else:
			first_class.append(n // 2)
			second_class.append(n - n // 2)
	for s in first_class:
		if s != 1:
			x += factorial(s) / (2 * factorial(s - 2))
	for s in second_class:
		if s != 1:
			x += factorial(s) / (2 * factorial(s - 2))
	print(int(x))
A()


from collections import Counter
from itertools import combinations
names = [input() for t in range(int(input()))]
count_dict = Counter([name[0] for name in names])
result = 0
for (k, v) in count_dict.items():
	if v > 2:
		class_1 = v // 2
		class_2 = v - class_1
		result += len([i for i in combinations(range(class_1), 2)]) + len([i for i in combinations(range(class_2), 2)])
print(result)


n = int(input())
l = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(n):
	a = ord(input()[0]) - 97
	l[a] += 1
sum = 0
for x in l:
	if x > 1:
		if x % 2 == 0:
			a = x // 2
			sum = sum + a * (a - 1)
		else:
			a = x // 2
			sum = sum + a ** 2
print(sum)


n = int(input())
lis = []
arr = []
(count, temp) = (0, 0)
for i in range(n):
	name = input()
	lis.append(name)
lis.sort()
for i in range(n - 1):
	if lis[i][0] == lis[i + 1][0]:
		temp += 1
	elif lis[i][0] != lis[i + 1][0]:
		flag = 1
		arr.append(temp + 1)
		temp = 0
	if i == n - 2:
		arr.append(temp + 1)
for i in range(len(arr)):
	if arr[i] > 2 and arr[i] % 2 == 0:
		arr[i] = arr[i] // 2
		count += arr[i] * (arr[i] - 1)
	elif arr[i] > 2 and arr[i] % 2 != 0:
		arr[i] = arr[i] // 2
		count += arr[i] * (arr[i] - 1) // 2 + (arr[i] + 1) * arr[i] // 2
print(count)


n = int(input())
d = {}
for i in range(0, n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
sm = 0
for i in d:
	mts = [d[i] // 2, d[i] // 2]
	if mts[0] + mts[1] != d[i]:
		mts[1] += 1
	sm += mts[0] * (mts[0] - 1) // 2
	sm += mts[1] * (mts[1] - 1) // 2
print(sm)


import math
n = int(input())
a = [str(input()) for i in range(n)]
b = [0] * 26
for i in a:
	c = ord(i[0]) - 96
	b[c - 1] = b[c - 1] + 1
chats = 0
for i in b:
	if i > 1 and i % 2 == 1:
		t = int(i / 2)
		if t == 1:
			chats = chats + 1
		elif t > 1:
			chats = chats + int(math.factorial(t) / (math.factorial(2) * math.factorial(t - 2))) + int(math.factorial(t + 1) / (math.factorial(2) * math.factorial(t + 1 - 2)))
	elif i > 1 and i % 2 == 0:
		t = int(i / 2)
		if t > 1:
			chats = chats + int(math.factorial(t) / (math.factorial(2) * math.factorial(t - 2))) * 2
print(chats)


from math import ceil, floor, factorial as f
from collections import defaultdict
n = int(input())
x = defaultdict(lambda : 0)
for i in range(n):
	x[input()[0]] += 1
c = 0
for v in x.values():
	if v > 2:
		vf = floor(v / 2)
		if vf > 1:
			c += f(vf) // f(2) // f(vf - 2)
		vc = ceil(v / 2)
		if vc > 1:
			c += f(vc) // f(2) // f(vc - 2)
print(c)


n = int(input())
mass = []
a = [0 for _ in range(26)]
sumi = 0
for i in range(n):
	tmp = ord(input()[0]) - 97
	a[tmp] += 1
for i in range(26):
	if a[i] == 3:
		sumi += 1
	elif a[i] > 3:
		tmp = a[i] // 2
		a[i] -= tmp
		sumi += sum(list(range(tmp)) + list(range(a[i])))
print(sumi)


n = int(input())
l = [input() for i in range(n)]
c = [0 for i in range(26)]
for i in l:
	c[ord(i[0]) - ord('a')] += 1
total = 0
for i in c:
	a = i // 2
	b = i - a
	total = total + a * (a - 1) // 2 + b * (b - 1) // 2
print(total)


import math

def chatting(a):
	res = 0
	h = {}
	a = [x[0] for x in a]
	for c in a:
		if c in h:
			h[c] += 1
		else:
			h[c] = 1
	for v in h.values():
		x = v // 2
		y = v - x
		res += x * (x - 1) // 2 + y * (y - 1) // 2
	return res
a = []
for _ in range(int(input())):
	a.append(input())
print(chatting(a))


a = []
b = []
for _ in range(int(input())):
	a.append(input())
b = []
for i in range(len(a)):
	b.append(a[i][0])
c = list(set(b))
d = [b.count(i) for i in c]
count = 0
for i in d:
	x = i // 2
	y = i - x
	count = count + x * (x - 1) / 2 + y * (y - 1) / 2
print(int(count))


def xxx(x):
	y = 1
	while x > 0:
		y *= x
		x -= 1
	return y

def yyy(x, y):
	return xxx(x) // xxx(x - y) // xxx(y)
a = [''] * 27
ai = 0
b = [0] * 27
for i in range(int(input())):
	x = input()[0]
	if x not in a:
		a[ai] = x
		b[ai] = 1
		ai += 1
	else:
		b[a.index(x)] += 1
q = 0
for i in b:
	if i == 0:
		break
	elif i % 2 == 0:
		q += xxx(i // 2) // xxx(i // 2 - 2)
		if i == 2:
			q -= xxx(i // 2) // xxx(i // 2 - 2)
	else:
		q += xxx(i // 2) // xxx(i // 2 - 2) // 2 + xxx(i // 2 + 1) // xxx(i // 2 - 1) // 2
print(q)


n = int(input())
a = [0] * 26
ans = 0
for i in range(n):
	s = input()
	a[ord(s[0]) - ord('a')] += 1
for i in range(26):
	if a[i] > 2:
		if a[i] % 2 == 1:
			t = a[i] // 2
			ans += (t + 1) * t // 2 + t * (t - 1) // 2
		else:
			t = a[i] // 2
			ans += t * (t - 1)
print(ans)


n = int(input())
l = []
for i in range(n):
	l.append(input())
f = []
for i in range(26):
	f.append(0)
x = 0
ls1 = []
ls2 = []
m = 0
j = 0
for i in range(n):
	s = l[i]
	k = ord(s[0])
	k = k - 97
	if s[0] not in ls1:
		ls1.append(s[0])
		f[k] = 0
	elif f[k] == 0:
		if s[0] not in ls2:
			ls2.append(s[0])
		else:
			ls1.append(s[0])
			m = ls1.count(s[0])
			m = m - 1
			x = x + m
			f[k] = 1
	else:
		ls2.append(s[0])
		j = ls2.count(s[0])
		j = j - 1
		x = x + j
		f[k] = 0
print(x)


s = []
f = []
for _ in range(int(input())):
	s.append(input())
s.sort()
cnt = 1
maxx = []
if len(s) == 1:
	print(0)
else:
	for i in range(len(s) - 1):
		if s[i][0] == s[i + 1][0]:
			cnt += 1
		else:
			maxx.append(cnt)
			cnt = 1
	if s[-1][0] == s[-2][0]:
		maxx.append(cnt)
	summ = 0
	for i in range(len(maxx)):
		if maxx[i] % 2 == 0:
			g = maxx[i] // 2
			summ += g * (g - 1) // 2 + g * (g - 1) // 2
		else:
			g = maxx[i] // 2
			x = g * (g - 1) // 2
			v = maxx[i] // 2 + 1
			y = v * (v - 1) // 2
			summ += x + y
	print(summ)


def calc(v):
	if v <= 0:
		return 0
	else:
		return int((1.0 + v) / 2.0 * v)
n = int(input())
names = [input() for i in range(n)]
d = {}
result = 0
for name in names:
	if not name[0] in d:
		d[name[0]] = []
	d[name[0]].append(name)
for key in d:
	count = len(d[key])
	result += calc(count // 2 - 1) + calc(count // 2 + count % 2 - 1)
print(result)


import math

def check(s):
	c = [0] * 40
	for i in s:
		c[ord(i) - 97] += 1
	s = 0
	for i in c:
		a1 = math.floor(i / 2)
		a2 = math.ceil(i / 2)
		s += a1 * (a1 - 1) / 2 + a2 * (a2 - 1) / 2
	return s
n = int(input())
s = ['o'] * n
for i in range(n):
	s[i] = input().split()[0][0]
print(int(check(s)))


import math
f = math.factorial
n = int(input())
hsh1 = {}
hash2 = {}
while n > 0:
	name = input()
	if name[0] not in hsh1:
		hsh1[name[0]] = 1
	elif name[0] not in hash2:
		hash2[name[0]] = 1
	else:
		a = hsh1[name[0]]
		b = hash2[name[0]]
		if a > b:
			hash2[name[0]] += 1
		else:
			hsh1[name[0]] += 1
	n -= 1
pairs = 0
for (i, val) in hsh1.items():
	if val == 1:
		continue
	pairs += f(val) / (2 * f(val - 2))
for (i, val) in hash2.items():
	if val == 1:
		continue
	pairs += f(val) / (2 * f(val - 2))
print(int(pairs))


N = int(input())
list = []
for i in range(N):
	list.append(input())
list.sort()
d = 0
j = 0
count = 0

def function(number):
	if number % 2 == 0:
		return number / 2 * (number / 2 - 1)
	else:
		return (number + 1) / 2 * ((number + 1) / 2 - 1) / 2 + ((number + 1) / 2 - 1) * ((number + 1) / 2 - 1 - 1) / 2
while j + 1 < len(list):
	if list[j][0] == list[j + 1][0]:
		count += 1
	if list[j][0] == list[j + 1][0] and j + 1 == len(list) - 1:
		d += function(count + 1)
	elif list[j][0] != list[j + 1][0]:
		d += function(count + 1)
		count = 0
	j += 1
print(int(d))


from itertools import combinations
n = int(input())
names = []
for _ in range(n):
	names.append(input()[0])
class1 = []
class2 = []
names.sort()
for i in range(len(names)):
	if i % 2 == 0:
		class1.append(names[i])
	else:
		class2.append(names[i])
x = 0
y = 0
s_class1 = list(set(class1))
s_class2 = list(set(class2))
for i in range(len(s_class1)):
	if class1.count(s_class1[i]) > 1:
		x = x + len(list(combinations('-' * class1.count(s_class1[i]), 2)))
for i in range(len(s_class2)):
	if class2.count(s_class2[i]) > 1:
		y = y + len(list(combinations('-' * class2.count(s_class2[i]), 2)))
print(x + y)


l = []
l1 = []
ans = 0
for i in range(int(input())):
	s = str(input())
	l.append(s[0])
s = set(l)
for i in s:
	l1.append(l.count(i))
for i in l1:
	a = i // 2
	b = i - a
	if i >= 3:
		ans = ans + a * (a - 1) // 2 + b * (b - 1) // 2
print(ans)


n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(s[0])
l1 = list(set(l))
p = len(l1)
c = 0
for i in range(p):
	m = l.count(l1[i])
	a = m // 2
	b = m - a
	c += a * (a - 1) // 2 + b * (b - 1) // 2
print(c)


import math
n = int(input())
l = [0] * 26
for i in range(n):
	a = input()
	l[ord(a[0]) - 97] += 1
f = math.factorial
sum = 0
for i in l:
	if i > 2:
		a = i // 2
		b = i - a
		if a > 1:
			sum += f(a) / f(a - 2) / f(2)
		sum += f(b) / f(b - 2) / f(2)
print(int(sum))


from collections import Counter
list1 = [input()[0] for i in range(int(input()))]
counter1 = Counter(list1)
func = lambda x, y: x * (x - 1) // 2 + y * (y - 1) // 2
print(sum((func(i // 2, i - i // 2) for i in counter1.values())))


from collections import defaultdict
import math
(FirstLetter, SUM) = (defaultdict(int), 0)
Times = lambda X: math.factorial(X) // (math.factorial(abs(X - 2)) * 2)
for i in range(int(input())):
	FirstLetter[input()[0]] += 1
print(sum((Times(i // 2) + Times(i - i // 2) for i in FirstLetter.values())))


n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(s[0])
m = set(l)
g = 0
for i in m:
	x = l.count(i)
	if x % 2 == 0:
		a = x // 2
		g += 2 * (a * (a - 1) // 2)
	else:
		a = x // 2
		b = a + 1
		g += a * (a - 1) // 2 + b * (b - 1) // 2
print(g)


n = int(input())
lis = [0] * 26
for i in range(n):
	s = input()
	lis[int(ord(s[0])) - int(ord('a'))] += 1
ans = 0
for i in lis:
	a = i // 2
	b = i - a
	ans += a * (a - 1) // 2 + b * (b - 1) // 2
print(ans)


n = int(input())
dic = {}
for i in range(n):
	name = input()[0]
	if name not in dic:
		dic[name] = 1
	else:
		dic[name] += 1
cnt = list(dic.values())
res = 0
for i in cnt:
	k = i // 2
	res += k * (k - 1) // 2
	k = i - k
	res += k * (k - 1) // 2
print(res)


n = int(input())
A = [0 for i in range(27)]
B = A.copy()
for i in range(n):
	j = ord(input()[0]) - ord('a')
	if A[j] > B[j]:
		B[j] += 1
	else:
		A[j] += 1
ans = 0
for i in A:
	ans += i * (i - 1) // 2
for i in B:
	ans += i * (i - 1) // 2
print(ans)


from math import floor, ceil
fact = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000, 51090942171709440000, 1124000727777607680000, 25852016738884976640000, 620448401733239439360000, 15511210043330985984000000, 403291461126605635584000000, 10888869450418352160768000000, 304888344611713860501504000000, 8841761993739701954543616000000, 265252859812191058636308480000000, 8222838654177922817725562880000000, 263130836933693530167218012160000000, 8683317618811886495518194401280000000, 295232799039604140847618609643520000000, 10333147966386144929666651337523200000000, 371993326789901217467999448150835200000000, 13763753091226345046315979581580902400000000, 523022617466601111760007224100074291200000000, 20397882081197443358640281739902897356800000000, 815915283247897734345611269596115894272000000000, 33452526613163807108170062053440751665152000000000, 1405006117752879898543142606244511569936384000000000, 60415263063373835637355132068513997507264512000000000, 2658271574788448768043625811014615890319638528000000000, 119622220865480194561963161495657715064383733760000000000, 5502622159812088949850305428800254892961651752960000000000, 258623241511168180642964355153611979969197632389120000000000, 12413915592536072670862289047373375038521486354677760000000000, 608281864034267560872252163321295376887552831379210240000000000, 30414093201713378043612608166064768844377641568960512000000000000, 1551118753287382280224243016469303211063259720016986112000000000000, 80658175170943878571660636856403766975289505440883277824000000000000, 4274883284060025564298013753389399649690343788366813724672000000000000, 230843697339241380472092742683027581083278564571807941132288000000000000, 12696403353658275925965100847566516959580321051449436762275840000000000000, 710998587804863451854045647463724949736497978881168458687447040000000000000, 40526919504877216755680601905432322134980384796226602145184481280000000000000, 2350561331282878571829474910515074683828862318181142924420699914240000000000000, 138683118545689835737939019720389406345902876772687432540821294940160000000000000, 8320987112741390144276341183223364380754172606361245952449277696409600000000000000, 507580213877224798800856812176625227226004528988036003099405939480985600000000000000, 31469973260387937525653122354950764088012280797258232192163168247821107200000000000000, 1982608315404440064116146708361898137544773690227268628106279599612729753600000000000000, 126886932185884164103433389335161480802865516174545192198801894375214704230400000000000000, 8247650592082470666723170306785496252186258551345437492922123134388955774976000000000000000, 544344939077443064003729240247842752644293064388798874532860126869671081148416000000000000000, 36471110918188685288249859096605464427167635314049524593701628500267962436943872000000000000000, 2480035542436830599600990418569171581047399201355367672371710738018221445712183296000000000000000, 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000, 11978571669969891796072783721689098736458938142546425857555362864628009582789845319680000000000000000, 850478588567862317521167644239926010288584608120796235886430763388588680378079017697280000000000000000, 61234458376886086861524070385274672740778091784697328983823014963978384987221689274204160000000000000000, 4470115461512684340891257138125051110076800700282905015819080092370422104067183317016903680000000000000000, 330788544151938641225953028221253782145683251820934971170611926835411235700971565459250872320000000000000000, 24809140811395398091946477116594033660926243886570122837795894512655842677572867409443815424000000000000000000, 1885494701666050254987932260861146558230394535379329335672487982961844043495537923117729972224000000000000000000, 145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000, 11324281178206297831457521158732046228731749579488251990048962825668835325234200766245086213177344000000000000000000, 894618213078297528685144171539831652069808216779571907213868063227837990693501860533361810841010176000000000000000000, 71569457046263802294811533723186532165584657342365752577109445058227039255480148842668944867280814080000000000000000000, 5797126020747367985879734231578109105412357244731625958745865049716390179693892056256184534249745940480000000000000000000, 475364333701284174842138206989404946643813294067993328617160934076743994734899148613007131808479167119360000000000000000000, 39455239697206586511897471180120610571436503407643446275224357528369751562996629334879591940103770870906880000000000000000000, 3314240134565353266999387579130131288000666286242049487118846032383059131291716864129885722968716753156177920000000000000000000, 281710411438055027694947944226061159480056634330574206405101912752560026159795933451040286452340924018275123200000000000000000000, 24227095383672732381765523203441259715284870552429381750838764496720162249742450276789464634901319465571660595200000000000000000000, 2107757298379527717213600518699389595229783738061356212322972511214654115727593174080683423236414793504734471782400000000000000000000, 185482642257398439114796845645546284380220968949399346684421580986889562184028199319100141244804501828416633516851200000000000000000000, 16507955160908461081216919262453619309839666236496541854913520707833171034378509739399912570787600662729080382999756800000000000000000000, 1485715964481761497309522733620825737885569961284688766942216863704985393094065876545992131370884059645617234469978112000000000000000000000, 135200152767840296255166568759495142147586866476906677791741734597153670771559994765685283954750449427751168336768008192000000000000000000000, 12438414054641307255475324325873553077577991715875414356840239582938137710983519518443046123837041347353107486982656753664000000000000000000000, 1156772507081641574759205162306240436214753229576413535186142281213246807121467315215203289516844845303838996289387078090752000000000000000000000, 108736615665674308027365285256786601004186803580182872307497374434045199869417927630229109214583415458560865651202385340530688000000000000000000000, 10329978488239059262599702099394727095397746340117372869212250571234293987594703124871765375385424468563282236864226607350415360000000000000000000000, 991677934870949689209571401541893801158183648651267795444376054838492222809091499987689476037000748982075094738965754305639874560000000000000000000000, 96192759682482119853328425949563698712343813919172976158104477319333745612481875498805879175589072651261284189679678167647067832320000000000000000000000, 9426890448883247745626185743057242473809693764078951663494238777294707070023223798882976159207729119823605850588608460429412647567360000000000000000000000, 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000, 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000]

def nCr(n, r):
	return fact[n] // (fact[r] * fact[n - r])
n = int(input().strip())
arr = []
for _ in range(n):
	arr += [input().strip()]
c = dict()
for i in range(n):
	key = arr[i][0]
	c[key] = c.get(key, 0) + 1
pairs = 0
for x in c.keys():
	first_class = floor(c[x] / 2)
	second_class = ceil(c[x] / 2)
	pairs += nCr(first_class, 2) + nCr(second_class, 2)
print(pairs)


n = int(input())
a = []
b = []
for i in range(n):
	s = input()
	a1 = a.count(s[0])
	b1 = b.count(s[0])
	if a1 < b1:
		a.append(s[0])
	else:
		b.append(s[0])
a2 = list(set(a))
a3 = []
for i in a2:
	a3.append(a.count(i))
b2 = list(set(b))
b3 = []
for i in b2:
	b3.append(b.count(i))
s = 0
for i in a3:
	s += i * (i - 1) // 2
for i in b3:
	s += i * (i - 1) // 2
print(s)


from math import factorial

def cnk(n, k):
	if n == 0 or n == 1:
		return 0
	return factorial(n) / factorial(n - k) / factorial(k)

def main():
	n = int(input())
	kids_dict = dict()
	first_class = list()
	second_class = list()
	for i in range(n):
		first_letter = input()[0]
		if first_letter not in kids_dict:
			kids_dict[first_letter] = 0
		kids_dict[first_letter] += 1
	for kid in kids_dict:
		first_kids = kids_dict[kid] // 2
		second_kids = kids_dict[kid] - first_kids
		first_class.append(first_kids)
		second_class.append(second_kids)
	first_result = 0
	second_result = 0
	for kids in first_class:
		first_result += cnk(kids, 2)
	for kids in second_class:
		second_result += cnk(kids, 2)
	print(int(first_result + second_result))
main()


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
n = int(input())
a = []
b = []
ans = 0
for i in range(n):
	a.append(input())
	b.append(a[i][0])
c = list(set(b))
for i in range(len(c)):
	a = b.count(c[i])
	if a > 1:
		x = a // 2
		y = a - x
		ans += int(nCr(x, 2)) + int(nCr(y, 2))
print(int(ans))


n = int(input())
x = 0
a = []
tmp = {}
for i in range(n):
	s = input()
	if tmp.get(s[0], -1) == -1:
		tmp[s[0]] = 1
	else:
		tmp[s[0]] += 1
for i in tmp.values():
	if i > 2:
		fi = i // 2
		se = i - fi
		if fi > 1:
			x += fi * (fi - 1) // 2
		if se > 1:
			x += se * (se - 1) // 2
print(x)


n = int(input())
listaNomes = [0] * 26
i = 0
res = 0
while i < n:
	nome = input()
	listaNomes[ord(nome[0]) - 97] += 1
	i += 1
for i in range(26):
	salaUm = listaNomes[i] // 2
	salaDois = listaNomes[i] - salaUm
	res += salaUm * (salaUm - 1) // 2
	res += salaDois * (salaDois - 1) // 2
print(res)


p = {}
for _ in range(int(input())):
	first_letter = input()[0]
	if first_letter in p:
		p[first_letter] += 1
	else:
		p[first_letter] = 1
x = 0
for letter in p:
	a = (p[letter] + 1) // 2
	b = p[letter] // 2
	x += (a * (a - 1) + b * (b - 1)) // 2
print(x)


n = int(input())
l = []
se = set()
for _ in range(n):
	st = input()
	s = st[0:1]
	l.append(s)
	se.add(s)
su = 0
for s in se:
	c = l.count(s)
	if c > 1:
		x = c // 2
		y = c - x
		su += (x * (x - 1) + y * (y - 1)) // 2
print(su)


from collections import defaultdict
d = dict()
for _ in range(int(input())):
	x = input()[0]
	d[x] = d.get(x, 0) + 1
ans = 0
for value in d.values():
	x = value // 2
	y = value - x
	ans = ans + x * (x - 1) // 2 + y * (y - 1) // 2
print(ans)


import math
x = int(input())
d = dict()
for i in range(x):
	a = input()
	if a[0] in d:
		d[a[0]] += 1
	else:
		d[a[0]] = 1
s = 0
for i in d:
	if d[i] == 3:
		s += 1
	elif d[i] > 3:
		m = d[i] // 2
		yo = m - 2
		C = math.factorial(m) // (math.factorial(yo) * math.factorial(2))
		if d[i] % 2 == 0:
			s += 2 * C
		else:
			i1 = m - 1
			C1 = math.factorial(m + 1) // (math.factorial(i1) * math.factorial(2))
			s += C1 + C
print(s)


import math

def fact(x):
	result = 1
	for i in range(x, 1, -1):
		result *= i
	return result

def comb(n, r):
	return fact(n) / (fact(n - r) * fact(r))
n = int(input().strip())
d = {}
for i in range(n):
	a = input().strip()
	d[a[0]] = d.get(a[0], []) + [a]
result = 0
for i in d:
	if len(d[i]) > 2:
		n = len(d[i])
		if n == 3:
			result += 1
		elif n % 2 == 0:
			result += comb(n // 2, 2) * 2
		else:
			result += comb(n // 2, 2) + comb(math.ceil(n / 2), 2)
print(int(result))


n = int(input())

def process():
	ch = []
	str = []
	t = 0
	result = 0
	for i in range(150):
		ch.append(int(0))
	for i in range(n):
		str.append(input())
	for i in range(n):
		tmp = str[i]
		t = ord(tmp[0])
		ch[t] += 1
	for i in range(123):
		x = ch[i] // 2
		y = ch[i] - x
		result += x * (x - 1) // 2
		result += y * (y - 1) // 2
	print(result)
process()


from collections import Counter
n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a[0])
s = Counter(l)
c = 0
for key in s:
	x = s[key] // 2
	y = s[key] - x
	c = c + x * (x - 1) + y * (y - 1)
print(c // 2)


n = int(input())
nums = [0 for x in range(26)]
for q in range(n):
	cur = input()
	nums[ord(cur[0]) - ord('a')] += 1
pairs = 0
for n in nums:
	oneHalf = n // 2
	otherHalf = n - oneHalf
	pairs += oneHalf * (oneHalf - 1) // 2
	pairs += otherHalf * (otherHalf - 1) // 2
print(pairs)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 998244353

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

def count(n):
	return n * (n + 1) // 2

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
mat = []
mydict = {chr(i): [] for i in range(97, 123)}
for i in range(n):
	name = input()
	mydict[name[0]].append(name)
total = 0
for i in mydict:
	length = len(mydict[i])
	if length & 1:
		total += count(length // 2) + count(length // 2 - 1)
	else:
		total += 2 * count(length // 2 - 1)
print(total)


a = []
b = []
n = int(input())
z = 0
for i in range(n):
	s = input()
	a.append(s)
	if s[0] not in b:
		b.append(s[0])
for i in b:
	c = 0
	for j in range(n):
		if i == a[j][0]:
			c = c + 1
	if c > 2:
		if c % 2:
			x = c // 2
			y = c // 2 + 1
			z = z + x * (x - 1) // 2 + y * (y - 1) // 2
		else:
			x = c // 2
			y = c // 2
			z = z + x * (x - 1) // 2 * 2
print(z)


n = int(input())
c = [0 for i in range(26)]
total = 0
for i in range(n):
	s = input()
	c[ord(s[0]) - ord('a')] += 1
for i in range(26):
	x = c[i] // 2
	y = c[i] - x
	x = x * (x - 1)
	y = y * (y - 1)
	x = x // 2
	y = y // 2
	total += x + y
print(total)


n = int(input())
mp = {}
for i in range(n):
	x = input()
	if not x[0] in mp:
		mp[x[0]] = 0
	mp[x[0]] += 1
ans = 0
for i in mp:
	x1 = mp[i] // 2
	x2 = mp[i] - x1
	ans += x1 * (x1 - 1) // 2 + x2 * (x2 - 1) // 2
print(ans)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
l = []
while n:
	n -= 1
	s = input()
	l.append(s[0])
dic = get_frequency(l)
couli = list(dic.values())
ans = 0
for i in range(len(couli)):
	if couli[i] > 2:
		if couli[i] % 2:
			one = couli[i] // 2
			two = one + 1
			ans += one * (one - 1) // 2 + two * (two - 1) // 2
		else:
			ans += couli[i] // 2 * (couli[i] // 2 - 1)
print(ans)


from collections import Counter
from itertools import combinations
n = int(input())
a = [input() for i in range(n)]
a = [i[0] for i in a]
c = Counter(a)
output = 0
for i in c:
	freq = c[i]
	x = freq // 2
	y = freq - x
	output += len(list(combinations([i for a in range(x)], 2)))
	output += len(list(combinations([i for a in range(y)], 2)))
print(output)


import sys

def input():
	return sys.stdin.readline().strip()
a = int(input())
c1 = dict()
c2 = c1.copy()
for i in range(a):
	s = input()
	if s[0] not in c1:
		c1[s[0]] = 1
	elif s[0] not in c2:
		c2[s[0]] = 1
	elif c1[s[0]] > c2[s[0]]:
		c2[s[0]] += 1
	else:
		c1[s[0]] += 1
s = 0
for i in c1:
	s += c1[i] * (c1[i] - 1) // 2
for i in c2:
	s += c2[i] * (c2[i] - 1) // 2
print(s)


t = input()
k = {}

def factorial(n):
	if n < 0:
		return 1
	if n == 0:
		return 1
	elif n in k:
		return k[n]
	else:
		lp = n * factorial(n - 1)
		k[n] = lp
		return lp
d = {}
for _ in range(int(t)):
	n = input().split()
	for i in n:
		if i[0] not in d:
			d[i[0]] = 0
		d[i[0]] += 1
x = 0
for i in d.values():
	x += factorial(i // 2) // (factorial(i // 2 - 2) * 2) + factorial(i - i // 2) // (factorial(i - i // 2 - 2) * 2)
print(x)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		t = self.next_int()
		cc = [0] * 26
		for _ in range(t):
			cc[ord(self.next()[0]) - ord('a')] += 1
		res = 0
		for c in cc:
			res += self.f(c // 2) + self.f(c - c // 2)
		print(res)

	def f(self, c):
		return c * (c - 1) // 2
Main().solve()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
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
import math, string

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())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	lets = dd(int)
	for n in range(N):
		S = getStr()
		lets[S[0]] += 1
	ans = 0

	def tri(x):
		return x * (x - 1) // 2
	for (letter, val) in lets.items():
		(A, B) = (val // 2, val - val // 2)
		ans += tri(A) + tri(B)
	return ans
print(solve())


n = int(input())
nomes = [''] * 100
resp = 0
for i in range(0, n):
	nomes[i] = input()
sala1 = [0] * 27
sala2 = [0] * 27
for i in range(0, n):
	if sala1[ord(nomes[i][0]) - 97] > sala2[ord(nomes[i][0]) - 97]:
		sala2[ord(nomes[i][0]) - 97] += 1
	else:
		sala1[ord(nomes[i][0]) - 97] += 1
for i in range(0, 27):
	if sala1[i] > 1:
		resp += sala1[i] * (sala1[i] - 1) / 2
	if sala2[i] > 1:
		resp += sala2[i] * (sala2[i] - 1) / 2
print(int(resp))


n = int(input())
lst = []
for i in range(n):
	lst.append(input())

def split_val(n):
	if n % 2 == 0:
		a = n // 2
		return a * (a - 1)
	else:
		a = n // 2
		return a * a
dic = {}
for i in lst:
	char = i[0]
	try:
		dic[char] += 1
	except:
		dic[char] = 1
sum = 0
for i in dic.values():
	sum = sum + split_val(i)
print(sum)


import io, os
input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
a = [input().strip() for _ in range(n)]
f = {c: 0 for c in 'abcdefghijklmnopqrstuvwxyz'}
for name in a:
	f[name[0]] += 1
ans = 0
for x in f.values():
	p = x // 2
	q = x - p
	ans += p * (p - 1) // 2
	ans += q * (q - 1) // 2
print(ans)


import os
import sys
from collections import Counter

def log(*args, **kwargs):
	if os.environ.get('CODEFR'):
		print(*args, **kwargs)
n = int(input())
c = Counter()
for i in range(n):
	s = input()
	c[s[0]] += 1
r = 0
for i in c.values():
	b = i // 2
	c = i - b
	d = b * (b - 1) / 2 + c * (c - 1) / 2
	r += d
print(int(r))


def sumtorial(n):
	sum = 0
	for i in range(n):
		sum += i
	return sum
n = int(input())
b = {}
for i in range(n):
	a = input()[0]
	if b.get(a) is not None:
		b[a] += 1
	else:
		b[a] = 1
sum = 0
for i in b:
	f = int(b[i])
	if f % 2 == 0:
		sum += 2 * sumtorial(f // 2)
	else:
		sum += sumtorial(f // 2) + sumtorial(f // 2 + 1)
print(sum)


import string

def main():
	n = int(input())
	lower = string.ascii_lowercase
	counts = {}
	for l in lower:
		counts[l] = 0
	for i in range(n):
		name = str(input())
		counts[name[0]] = counts[name[0]] + 1
	ans = 0
	for i in counts.keys():
		if counts[i] != 0:
			left = counts[i] // 2
			right = counts[i] - left
			ans += left * (left - 1) // 2 + right * (right - 1) // 2
	print(ans)
main()


t = []
for i in range(int(input())):
	t.append(input()[0])
p = list(set(t))
x = 0
for j in p:
	if t.count(j) > 2:
		b = t.count(j)
		u = b // 2
		if b % 2 == 0:
			x += u * (u - 1)
		else:
			x += u * (u - 1) // 2 + u * (u + 1) // 2
print(x)


n = int(input())
ar = {}
rez = 0
for i in range(n):
	k = input()[0]
	if k not in ar:
		ar[k] = 0
	rez += ar[k] // 2
	ar[k] += 1
print(rez)


n = int(input())
a = []
for i in range(n):
	b = input()
	a.append(b)
b = []
c = []
for i in range(n):
	count = 0
	if a[i][0] in b:
		continue
	for j in range(i, n):
		if a[i][0] == a[j][0]:
			count += 1
	b.append(a[i][0])
	c.append(count)
count = 0
for i in c:
	if i == 1 or i == 2:
		continue
	else:
		k = i // 2
		k1 = i - k
		count = count + k * (k - 1) // 2 + k1 * (k1 - 1) // 2
print(count)


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


import collections
n = int(input())
member = []
for i in range(n):
	member.append(input()[0])
c = collections.Counter(member)
c = c.most_common()
num = []
for i in range(len(c)):
	num.append(c[i][1])
ans = 0
for i in range(len(num)):
	a = num[i] // 2
	ans += a * (a - 1) // 2
	b = num[i] - num[i] // 2
	ans += b * (b - 1) // 2
print(ans)


a = int(input())
b = []
for i in range(0, a):
	b.append(input()[0:1])
c = []
d = []
count = 0
for i in range(0, a):
	if b[i] not in c:
		e = b.count(b[i])
		d.append(e)
		c.append(b[i])
for i in range(len(d)):
	x = d[i] // 2
	y = d[i] - x
	if x % 2 == 0 and x > 1:
		z = x // 2
		w = (z - 1) * x + z
		count = count + w
	elif x > 1:
		z = x // 2
		w = z * x
		count = count + w
	if y % 2 == 0 and y > 1:
		z = y // 2
		w = (z - 1) * y + z
		count = count + w
	elif y > 1:
		z = y // 2
		w = z * y
		count = count + w
print(count)


from math import factorial
n = int(input())
l = []
res = 0
for i in range(n):
	s = input()
	l.append(s[0])
k = set(l)
for i in k:
	r = l.count(i)
	x = r // 2
	if r == 3:
		res += 1
	elif r >= 4:
		res += factorial(x) // (factorial(x - 2) * 2) + factorial(r - x) // (factorial(r - x - 2) * 2)
print(res)


import math

def nCr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
n = int(input())
l = []
(f, c, sum, g1, g2) = (0,) * 5
for line in range(n):
	l.append(input()[0])
my_dict = {i: l.count(i) for i in l}
for (letter, j) in my_dict.items():
	(g1, g2) = (0,) * 2
	if j != 1:
		f = math.floor(j / 2)
		c = math.ceil(j / 2)
		if f != 1:
			g1 = nCr(f, 2)
		if c != 1:
			g2 = nCr(c, 2)
		sum += int(g1 + g2)
print(sum)


n = int(input())
s = [[] for i in range(n)]
for i in range(n):
	s[i] = input()
c = [0] * 26
for i in range(n):
	c[ord(s[i][0]) - 97] += 1
co = 0
for i in range(26):
	if c[i] % 2 == 0:
		co += c[i] // 2 * (c[i] // 2 - 1)
	else:
		co += c[i] // 2 * (c[i] // 2 - 1) // 2 + c[i] // 2 * (c[i] // 2 + 1) // 2
print(co)


import atexit
import io
import sys
from collections import Counter
R = lambda : map(int, input().split())
lst1 = []
for i in range(int(input())):
	lst1.append(input())
dict = {}
for i in lst1:
	if i[0] not in dict:
		dict[i[0]] = 1
	else:
		dict[i[0]] += 1
ans = 0
for i in dict.values():
	temp = i // 2
	temp1 = i - temp
	ans += temp * (temp - 1) // 2 + temp1 * (temp1 - 1) // 2
print(ans)


def fun(n):
	return n * (n - 1) / 2
import math
n = int(input())
a = []
for i in range(0, n):
	s = input()
	a.append(s[0])
a.sort()
i = 0
ans = 0
k = set(a)
for i in k:
	temp = 0
	for j in range(0, n):
		if i == a[j]:
			temp += 1
	if temp % 2 == 0:
		ans += 2 * fun(temp / 2)
	else:
		ans += fun((temp - 1) / 2) + fun((temp + 1) / 2)
print(int(ans))


n = int(input())
s1 = ''
s2 = ''
for i in range(0, n):
	a = input()
	if a[0] not in s1:
		s1 += a[0]
	s2 += a[0]
su = 0
for i in range(0, len(s1)):
	t = s2.count(s1[i])
	p1 = t // 2 + t % 2
	p2 = t // 2
	if p1 % 2 == 0:
		su += (p1 - 1) * (p1 // 2)
	else:
		su += p1 * (p1 // 2)
	if p2 % 2 == 0:
		su += (p2 - 1) * (p2 // 2)
	else:
		su += p2 * (p2 // 2)
print(su)


def combi(num):
	if num <= 1:
		return 0
	else:
		return num * (num - 1) // 2
dic = {}
for x in range(int(input())):
	s = input()
	dic[s[0]] = dic[s[0]] + 1 if s[0] in dic else 1
sum = 0
for x in dic.keys():
	sum += combi(dic[x] // 2) + combi(dic[x] - dic[x] // 2)
print(sum)


import math
from sys import stdin
n = int(stdin.readline().rstrip())
d = {}
for i in range(n):
	s = stdin.readline().rstrip()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
s = 0
for i in d:
	a = int(math.ceil(d[i] / 2))
	b = int(math.floor(d[i] / 2))
	s += int(a * (a - 1) / 2) + int(b * (b - 1) / 2)
print(s)


n = int(input())
d = {}
for i in range(n):
	a = input()
	if a[0] in d:
		d[a[0]] += 1
	else:
		d[a[0]] = 1
res = 0
for (i, j) in d.items():
	a = j // 2
	b = j - a
	res += a * (a - 1) // 2
	res += b * (b - 1) // 2
print(res)


n = int(input())
s = {}
res = 0
for i in range(n):
	name = input()
	if name[0] not in s:
		s[name[0]] = 1
	else:
		s[name[0]] += 1
for i in s.values():
	if i > 2:
		if i % 2 == 0:
			res += i // 2 * (i // 2 - 1)
		else:
			res += i // 2 * (i // 2 - 1) // 2
			res += (i // 2 + 1) * (i // 2) // 2
print(res)


import collections
import math
num = int(input())
L = []
for i in range(num):
	a = input()
	L.append(a[:1])
counter = collections.Counter(L)
s = 0
for (k, v) in dict(counter).items():
	v = v / 2
	b = math.floor(v)
	c = math.ceil(v)
	d = b * (b - 1) / 2 + c * (c - 1) / 2
	s = s + d
print(int(s))


n = int(input())
S = []
for i in range(n):
	S.append(input()[0])
S = sorted(S)
K = list(set(S))
summ = 0
for i in K:
	j = S.count(i)
	if j == 0 or j == 1 or j == 2:
		summ += 0
	elif j == 3:
		summ += 1
	elif j == 4:
		summ += 2
	elif j == 5:
		summ += 4
	elif j == 6:
		summ += 6
	else:
		summ += 6
		for kk in range(j - 6):
			summ += kk // 2 + 3
print(summ)


def f(x):
	return x * (x - 1) // 2
n = int(input())
A = [input() for i in range(n)]
A.sort()
ans = i = 0
while i < n:
	j = i
	while j < n and A[i][0:1] == A[j][0:1]:
		j += 1
	if j - i % 2 == 0:
		ans += f((j - i) // 2) * 2
	else:
		ans += f((j - i + 1) // 2) + f((j - i) // 2)
	i = j
print(ans)


def main():
	ri = lambda : int(input())
	rci = lambda : list(map(int, input().split()))
	pc = lambda c: print(''.join(map(str, c)))
	pcr = lambda c: print(' '.join(map(str, c)))
	from math import factorial
	n = ri()
	d = {}
	k = 0
	for i in range(n):
		a = input()
		if a[0] in d:
			d[a[0]] += 1
		else:
			d[a[0]] = 1
	for i in list(d.values()):
		if i == 3:
			k += 1
		elif i > 3:
			n = i // 2
			k += n * (n - 1) // 2
			k += (i - n) * (i - n - 1) // 2
	print(k)
	return 0
main()


n = int(input())
eleves = []
(alpha, alpha1, alpha2) = ([0] * 26, [0] * 26, [0] * 26)
(gp1, gp2) = ([], [])
for i in range(n):
	el = str(input())
	eleves.append(el)
	cap = ord(eleves[i][0]) - 97
	alpha[cap] += 1
	if alpha[cap] % 2 == 0:
		gp1.append(eleves[i])
		alpha1[cap] += 1
	else:
		gp2.append(eleves[i])
		alpha2[cap] += 1
ans = 0
for i in range(26):
	m = alpha1[i]
	p = alpha2[i]
	ans += m * (m - 1) // 2 + p * (p - 1) // 2
print(ans)


n = int(input())
c1 = []
c2 = []
for i in range(n):
	name = input()
	cnt1 = 0
	cnt2 = 0
	for i in c1:
		if i[0] == name[0]:
			cnt1 += 1
	for i in c2:
		if i[0] == name[0]:
			cnt2 += 1
	if cnt1 < cnt2:
		c1.append(name)
	else:
		c2.append(name)
count = 0
k = 0
for i in range(len(c1)):
	let = c1[i][0]
	for j in range(i + 1, len(c1)):
		if c1[j][0] == let:
			count += 1
for i in range(len(c2)):
	let = c2[i][0]
	for j in range(i + 1, len(c2)):
		if c2[j][0] == let:
			count += 1
print(count)


from math import factorial
n = int(input())
d = {}
ans = 0
for x in range(n):
	s = input()
	if s[0] not in d:
		d[s[0]] = 1
	else:
		d[s[0]] += 1
for (key, val) in d.items():
	if val > 2:
		split = val // 2
		split2 = val - split
		ans += factorial(split2) / (factorial(2) * factorial(split2 - 2))
		if split > 1:
			ans += factorial(split) / (factorial(2) * factorial(split - 2))
print(int(ans))


n = int(input())
a = [0] * 26
for i in range(n):
	s = input()
	a[ord(s[0]) - ord('a')] += 1
ans = 0
for i in range(26):
	f = a[i] // 2
	s = a[i] - f
	ans += f * (f - 1) // 2 + s * (s - 1) // 2
print(ans)


N = int(input())
list = []

def function(Integer):
	if Integer % 2 == 0:
		return Integer / 2 * (Integer / 2 - 1)
	else:
		a = (Integer + 1) / 2
		return a * (a - 1) / 2 + (a - 1) * (a - 2) / 2
for i in range(N):
	list.append(input())
dict = {}
for i in list:
	dict[i[0]] = 0
for i in list:
	dict[i[0]] += 1
count = 0
for i in dict:
	count += function(dict[i])
print(int(count))


d = {}
for _ in range(int(input())):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
cnt = 0
for i in d.keys():
	z = d[i]
	ph = z // 2
	cnt += ph * (ph - 1) // 2 + (z - ph) * (z - ph - 1) // 2
print(cnt)


from collections import *
a = Counter((input()[0] for _ in [0] * int(input())))
r = 0
for k in a:
	i = a[k] // 2
	j = a[k] - i
	r += i * (i - 1) + j * (j - 1)
print(r // 2)


RI = lambda : [int(x) for x in input().split()]
from collections import defaultdict as df
import sys

def comb(n, c):
	if n == 1 or n == 0:
		return 0
	res = 1
	for i in range(0, n - c):
		res *= n - i
		res /= i + 1
	return res
n = int(input())
l = []
d = df(int)
for i in range(n):
	l.append(input())
	d[l[i][0]] += 1
ans = 0
for i in d:
	ans += comb(d[i] // 2, 2) + comb((d[i] + 1) // 2, 2)
print(int(ans))


from sys import *
from math import *
from collections import *
M = {}
n = int(input())
for i in range(n):
	s = input()
	if s[0] not in M:
		M[s[0]] = 1
	else:
		M[s[0]] += 1
ans = 0
for m in M:
	if M[m] > 2:
		l = M[m] // 2
		r = M[m] - l
		if l >= 2:
			ans += l * (l - 1) // 2
		if r >= 2:
			ans += r * (r - 1) // 2
print(ans)


n = int(input())
from collections import defaultdict
c = defaultdict(int)
for _ in range(n):
	name = input()
	c[name[0]] += 1
total = 0
for (k, v) in c.items():
	left = v // 2
	right = (v + 1) // 2
	total += left * (left - 1) // 2
	total += right * (right - 1) // 2
print(total)


def f(n):
	return n * (n - 1) // 2

def main():
	n = int(input())
	inp = []
	ans = 0
	for _ in range(n):
		inp.append(input()[0])
	for c in set(inp):
		tmp = inp.count(c)
		h = tmp // 2
		ans += f(h) + f(tmp - h)
	print(ans)
main()


n = int(input())
alphadict = {}
a = []
for i in range(n):
	a.append(input())
nom = []
for i in range(len(a)):
	alpha = a[i][0]
	if alpha not in alphadict:
		alphadict[alpha] = 1
	else:
		alphadict[alpha] = alphadict[alpha] + 1
minimum = 0
for y in alphadict:
	x = alphadict[y]
	if x == 1:
		minimum += 0
	elif x % 2 == 0:
		minimum += x // 2 * (x // 2 - 1)
	else:
		minimum += x // 2 * (x // 2 - 1) / 2
		minimum += (x // 2 + 1) * (x // 2) / 2
minimum = int(minimum)
print(minimum)


n = int(input())
l = [0] * 27
i = 0
while i < n:
	s = input()
	l[ord(s[0]) - 97] += 1
	i += 1
sum = 0
for i in range(27):
	n1 = l[i] // 2
	n2 = l[i] - n1
	sum += n1 * (n1 - 1) // 2 + n2 * (n2 - 1) // 2
print(sum)


n = int(input())
(g1, g2) = ({}, {})
x = 0
for i in range(n):
	firstLetter = input()[0]
	if firstLetter in g1:
		if firstLetter in g2:
			if g2[firstLetter] < g1[firstLetter]:
				x += g2[firstLetter]
				g2[firstLetter] += 1
			else:
				x += g1[firstLetter]
				g1[firstLetter] += 1
		else:
			g2[firstLetter] = 1
	else:
		g1[firstLetter] = 1
print(x)


n = int(input())
hashi = dict()
ans = 0
for i in range(n):
	s = input()
	z = s[0]
	if z in hashi:
		hashi[z] += 1
	else:
		hashi[z] = 1
for i in hashi:
	k = (hashi[i] + 1) // 2
	z = hashi[i] - k
	ans += k * (k - 1) // 2
	ans += z * (z - 1) // 2
print(ans)


def sm(x):
	return x * (x - 1) // 2
p = [input()[0] for i in range(int(input()))]
k = set(p)
m = 0
for i in k:
	t = p.count(i)
	if t % 2 == 0:
		m += 2 * sm(t // 2)
	elif t != 1:
		m += sm(t // 2) + sm(t // 2 + 1)
print(m)


n = int(input())
names = {}
for i in range(n):
	name = input()
	if name[0] in names:
		names[name[0]] += 1
	else:
		names[name[0]] = 1
count = 0
for i in names:
	if names[i] >= 2:
		if names[i] % 2 == 0:
			num = names[i] // 2 * (names[i] // 2 - 1)
		else:
			num = names[i] // 2 * (names[i] // 2 - 1) // 2 + names[i] // 2 * (names[i] // 2 + 1) // 2
		count += num
print(count)


n = int(input())
m = []
ct = 0

def tent(x):
	return x * (x - 1) // 2
for _ in range(n):
	s = input()
	m.append(s[0])
	x = list(set(m))
for r in x:
	if m.count(r) > 2:
		e = m.count(r)
		a = e // 2
		b = e - a
		ct += tent(a)
		ct += tent(b)
print(ct)


beta = [0] * 26
n = int(input())

def factor(j):
	if j == 0:
		return 1
	else:
		return j * factor(j - 1)

def c(u):
	if u <= 1:
		return 0
	else:
		return int(factor(u) / (2 * factor(u - 2)))
while n:
	s = input()
	beta[ord(s[0]) - 97] += 1
	n -= 1
res = 0
for i in range(26):
	res += c(beta[i] // 2) + c(beta[i] - beta[i] // 2)
print(res)


n = int(input())
a = []
letters = set()
for _ in range(n):
	letter = input()[0]
	a.append(letter)
	letters.add(letter)
sol = 0
for x in letters:
	oneCount = a.count(x) // 2
	twoCount = a.count(x) - oneCount
	sol += oneCount * (oneCount - 1) // 2
	sol += twoCount * (twoCount - 1) // 2
print(sol)


n = int(input())
letters = []
qtdA = 0
qtdB = 0
for i in range(n):
	name = input()
	letters.append(name[0])
letters.sort()
lastL = letters[0]
vez = 0
qtdA = 0
qtdB = 0
qtd = 0
for i in range(n):
	if letters[i] == lastL:
		qtd += 1
	else:
		if qtdA < qtdB:
			met = qtd // 2
			metA = met + qtd % 2
			metB = met
			qtdA += max(0, metA * (metA - 1) // 2)
			qtdB += max(0, metB * (metB - 1) // 2)
		else:
			met = qtd // 2
			metB = met + qtd % 2
			metA = met
			qtdA += max(0, metA * (metA - 1) // 2)
			qtdB += max(0, metB * (metB - 1) // 2)
		qtd = 1
	lastL = letters[i]
if qtdA < qtdB:
	met = qtd // 2
	metA = met + qtd % 2
	metB = met
	qtdA += max(0, metA * (metA - 1) // 2)
	qtdB += max(0, metB * (metB - 1) // 2)
else:
	met = qtd // 2
	metB = met + qtd % 2
	metA = met
	qtdA += max(0, metA * (metA - 1) // 2)
	qtdB += max(0, metB * (metB - 1) // 2)
print(qtdA + qtdB)


def main():

	def factorielle(n):
		if n == 0:
			return 1
		else:
			return n * factorielle(n - 1)

	def binomial(a, b):
		if a > b:
			return 0
		else:
			return factorielle(b) / (factorielle(a) * factorielle(b - a))
	nb = int(input())
	etudiants = []
	for i in range(nb):
		etudiants.append(list(input())[0])
	alphabet = [0] * 26
	for i in etudiants:
		alphabet[ord(i) - 97] += 1
	somme = 0
	for i in alphabet:
		classe1 = i // 2
		classe2 = (i + 1) // 2
		somme += binomial(2, classe1)
		somme += binomial(2, classe2)
	print(int(somme))
main()


a = int(input())
b = {}
for j in range(a):
	c = input()[0]
	if c not in b:
		b[c] = 1
	else:
		b[c] += 1
c = 0
for (x, y) in b.items():
	if y > 2:
		e = y // 2
		o = y // 2
		if y % 2 == 1:
			e += 1
		t = e * (e - 1) // 2
		w = o * (o - 1) // 2
		c += t + w
print(c)


n = int(input())
names = [input()[0] for _ in range(n)]
(c1, c2) = ({}, {})
a = [0] * 51
for i in range(1, 51):
	a[i] = a[i - 1] + i
for e in names:
	m1 = c1.get(e, None)
	if m1 == None:
		c1[e] = 1
	else:
		m2 = c2.get(e, None)
		if m2 == None:
			c2[e] = 1
		elif m1 < m2:
			c1[e] += 1
		else:
			c2[e] += 1
x = 0
for e in c1.values():
	x += a[e - 1]
for e in c2.values():
	x += a[e - 1]
print(x)


from collections import Counter
from string import ascii_lowercase
N = int(input())
names = [input().strip() for _ in range(N)]
ct = Counter((n[0] for n in names))
ans = 0
for x in ascii_lowercase:
	c = ct[x]
	y = c // 2
	ans += y * (y - 1) // 2 + (c - y) * (c - y - 1) // 2
print(ans)


from sys import stdin, setrecursionlimit
from bisect import bisect_right
import math
setrecursionlimit(15000)
n = int(stdin.readline().strip())
names = []
for _ in range(n):
	names.append(stdin.readline().strip())
x1 = 0
x2 = 0
x = 0
first = []
second = []
for i in range(n):
	c = names[i][0]
	x1 = 0
	x2 = 0
	for l in second:
		if l == c:
			x1 += 1
	for l in first:
		if l == c:
			x2 += 1
	if x1 < x2:
		x += x1
		second.append(c)
	else:
		x += x2
		first.append(c)
print(x)


import sys
from collections import Counter
from itertools import combinations

def read_line():
	return sys.stdin.readline().split()

def read_int_iter():
	return map(int, read_line())

def read_int_array():
	return list(read_int_iter())

def init_array(n, default=0):
	return [default] * n

def iota(n, start=0):
	return list(range(start, n))

def print_iter(a):
	sys.stdout.write(' '.join(map(str, a)) + '\n')

def problem_a():
	n = int(sys.stdin.readline())
	factorial = [1] * 101
	for i in range(2, 101):
		factorial[i] = i * factorial[i - 1]

	def combinations_number(n):
		k = 2
		if n < k:
			return 0
		return factorial[n] // (k * factorial[n - k])
	counter = Counter()
	for _ in range(n):
		name = sys.stdin.readline()
		counter[name[0]] += 1
	total = 0
	for count in counter.values():
		first_class = count // 2
		second_class = count - first_class
		total += combinations_number(first_class) + combinations_number(second_class)
	print(total)
problem_a()

def problem_b():
	pass

def problem_c():
	pass

def problem_d():
	pass

def problem_e():
	pass

def problem_f():
	pass

def problem_g():
	pass

def problem_h():
	pass


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
d = {}
for _ in range(num):
	t = z()[0]
	try:
		d[t] += 1
	except:
		d[t] = 1
lst = sorted(list(d.values()))[::-1]
ans = 0
for i in lst:
	t1 = i // 2
	t2 = i - t1
	ans += t1 * (t1 - 1) // 2 + t2 * (t2 - 1) // 2
print(ans)


n = int(input().strip())
names = []
for k in range(n):
	names.append(input().strip())
nn = [0 for i in range(26)]
for x in names:
	nn[ord(x[0]) - ord('a')] += 1
s = 0
import math
for k in range(26):
	if nn[k] == 3:
		s = s + 1
	if nn[k] > 3:
		p = math.ceil(nn[k] / 2)
		pp = math.floor(nn[k] / 2)
		s = s + p * (p - 1) // 2
		s = s + pp * (pp - 1) // 2
print(s)


def apsum(num):
	sum = num * (2 + (num - 1)) / 2
	return sum
t = int(input())
letters = dict()
count = 0
for i in range(t):
	name = input()
	first = name[0]
	if first in letters:
		letters[first] += 1
	else:
		letters[first] = 1
for let in letters:
	n = letters[let]
	count += apsum(n // 2 - 1)
	count += apsum(n - n // 2 - 1)
print(int(count))


import string
names = {c: 0 for c in string.ascii_lowercase}
for _ in range(int(input())):
	names[input()[0]] += 1
c = 0
f = lambda n: n * (n - 1) // 2
for k in names:
	c += f(names[k] // 2) + f(-(-names[k] // 2))
print(c)


n = int(input())
a = {}
b = {}
for _ in range(n):
	i = input()[0]
	if i not in a:
		a[i] = 1
	elif i not in b:
		b[i] = 1
	elif a[i] < b[i]:
		a[i] += 1
	else:
		b[i] += 1
c = {}
d = {}
for (i, j) in a.items():
	if j > 1:
		c[i] = j
for (i, j) in b.items():
	if j > 1:
		d[i] = j
ans = 0
for j in c.values():
	ans += j * (j - 1) // 2
for j in d.values():
	ans += j * (j - 1) // 2
print(ans)


n = int(input())
counter = {}
ans = 0
for i in range(n):
	name = input()
	if name[0] in counter:
		counter[name[0]] += 1
	else:
		counter[name[0]] = 1
for i in counter:
	if counter[i] % 2 == 0:
		n1 = counter[i] / 2
		n2 = n1
	elif counter[i] == 1:
		n1 = 0
		n2 = 0
	else:
		n1 = counter[i] // 2
		n2 = n1 + 1
	tri1 = (n1 - 1) / 2 * n1
	tri2 = (n2 - 1) / 2 * n2
	ans += tri1 + tri2
print(f'{ans:.0f}')


n = int(input())
l1 = list()
l2 = list()
l3 = list()
l4 = list()
c = 0
for i in range(n):
	s = input()
	if s[0] in l1 and s[0] not in l2:
		l2.append(s[0])
	elif s[0] in l2 and s[0] not in l1:
		l1.append(s[0])
	elif s[0] in l1 and s[0] in l2:
		if l1.count(s[0]) > l2.count(s[0]):
			l2.append(s[0])
		else:
			l1.append(s[0])
	elif s[0] not in l1 and s[0] not in l2:
		l1.append(s[0])
for j in l1:
	if j not in l3:
		l3.append(j)
for k in l2:
	if k not in l4:
		l4.append(k)
for i in l3:
	c += l1.count(i) * (l1.count(i) - 1) / 2
for i in l4:
	c += l2.count(i) * (l2.count(i) - 1) / 2
print(int(c))


n = int(input())
ar = []
for i in range(n):
	ar.append(input())
ar.sort()
ans = 0
num = 1
for i in range(1, n):
	if ar[i][0] == ar[i - 1][0]:
		num += 1
	else:
		a = num // 2
		b = num // 2
		if num % 2 == 1:
			b += 1
		ans += a * (a - 1) // 2
		ans += b * (b - 1) // 2
		num = 1
a = num // 2
b = num // 2
if num % 2 == 1:
	b += 1
ans += a * (a - 1) // 2
ans += b * (b - 1) // 2
print(ans)


from collections import *
a = Counter((input()[0] for _ in [0] * int(input())))
r = 0
for k in a:
	v = a[k]
	i = v // 2
	r += i * i + (v - i) ** 2 - v
print(r // 2)


import sys, heapq
from collections import deque, defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
DBG = True

def ddprint(x):
	if DBG:
		print(x)
n = inn()
a = defaultdict(int)
for i in range(n):
	s = input()
	a[s[0]] += 1
sum = 0
for c in a:
	x = a[c]
	y = x // 2
	if x % 2 == 0:
		sum += y * (y - 1)
	else:
		sum += y * y
print(sum)


import sys
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl = lambda : list(map(int, sys.stdin.readline().split()))
readt = lambda : tuple(map(int, sys.stdin.readline().split()))
readts = lambda : tuple(map(int, sys.stdin.readline().split()))
read = lambda : sys.stdin.readline().rstrip()
readi = lambda : int(read())
readmi = lambda : map(int, sys.stdin.readline().split())
readms = lambda : map(str, sys.stdin.readline().split())
n = readi()
a = defaultdict(int)
b = defaultdict(int)
for i in range(n):
	p = read()
	if not a[p[0]]:
		a[p[0]] = 0
	if not b[p[0]]:
		b[p[0]] = 0
	if a[p[0]] > b[p[0]]:
		b[p[0]] += 1
	else:
		a[p[0]] += 1
count = 0
k = defaultdict(int)
kk = 0
for i in range(1, 101):
	k[i] = kk
	kk += i
for i in a:
	count += k[a[i]]
for i in b:
	count += k[b[i]]
print(count)


n = int(input())
l = []
d = {}
d1 = {}
d2 = {}
c = 0
for i in range(97, 123):
	d[chr(i)] = 0
	d2[chr(i)] = 0
	d1[chr(i)] = 0
for i in range(n):
	s = input()
	l.append(s[0])
	d[s[0]] += 1
for i in range(97, 123):
	d1[chr(i)] += d[chr(i)] // 2
	d2[chr(i)] += d[chr(i)] - d[chr(i)] // 2
for i in range(97, 123):
	x = d1[chr(i)]
	y = d2[chr(i)]
	c += x * (x - 1) / 2
	c += y * (y - 1) / 2
print(int(c))


d = {}
for _ in range(int(input())):
	s = input()
	if s[0] not in d:
		d[s[0]] = 1
	else:
		d[s[0]] += 1
b = []
for i in d:
	if d[i] > 2:
		b.append(d[i])
(x1, x2) = (0, 0)
for i in range(len(b)):
	f = b[i] // 2
	g = b[i] - f
	x1 += f * (f - 1) // 2
	x2 += g * (g - 1) // 2
print(x1 + x2)


import math
l = []
t = []
comb = []
for _ in range(int(input())):
	l.append(input()[0])
for num in l:
	if num not in t:
		t.append(num)
		n = l.count(num)
		if n >= 3:
			r1 = n // 2
			r2 = n - r1
			if r1 >= 2:
				comb.append(math.factorial(r1) / (2 * math.factorial(r1 - 2)))
			comb.append(math.factorial(r2) / (2 * math.factorial(r2 - 2)))
print(int(sum(comb)))


from math import ceil, floor, factorial
t = 0

def nCr(n, r):
	m = factorial(n) / (factorial(n - r) * factorial(r))
	return m
a = []
for x in range(int(input())):
	a.append(input())
b = [a[x][0] for x in range(len(a))]
l = list(set(b))
c = [b.count(l[x]) for x in range(len(l))]
for x in range(len(c)):
	if c[x] == 1:
		pass
	else:
		q = ceil(c[x] / 2)
		w = floor(c[x] / 2)
		if q > 1 and w > 1:
			t += nCr(q, 2) + nCr(w, 2)
		elif q > 1 and w <= 1:
			t += nCr(q, 2)
		elif q <= 1 and w > 1:
			t += nCr(w, 2)
print(int(t))


from math import factorial

def comb(n):
	a = factorial(n) / (2 * factorial(n - 2))
	return a
n = int(input())
names = []
freq = dict()
for i in range(n):
	names.append(str(input())[0])
	freq[names[i]] = 0
names.sort()
ans = 0
for x in names:
	freq[x] += 1
for x in freq.keys():
	if freq[x] == 1 or freq[x] == 2:
		continue
	elif freq[x] == 3:
		ans += 1
	elif freq[x] == 4:
		ans += 2
	else:
		ans += comb(freq[x] // 2) + comb(freq[x] // 2 + freq[x] % 2)
print(int(ans))


from collections import Counter
N = int(input())
S = Counter()
for _ in range(N):
	s = input()
	S[s[0]] += 1
ans = 0
for v in S.values():
	a = v // 2
	b = v - a
	ans += (a * (a - 1) + b * (b - 1)) // 2
print(ans)


clas_1 = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
clas_2 = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
n = int(input())
for i in range(n):
	st = input().lower()
	if clas_1[st[0]] % 2 == clas_2[st[0]] % 2:
		clas_1[st[0]] += 1
	else:
		clas_2[st[0]] += 1
s = 0
for i in clas_1.values():
	if i > 1:
		s = s + i * (i - 1) // 2
for i in clas_2.values():
	if i > 1:
		s = s + i * (i - 1) // 2
print(s)


from collections import Counter
C = Counter()
n = int(input())
for _ in range(n):
	A = input()
	C[A[0]] += 1
result = 0
for (key, val) in C.items():
	(small, big) = (val // 2, val - val // 2)
	result += small * (small - 1) // 2 + big * (big - 1) // 2
print(result)


n = int(input())
s = [input() for i in range(n)]
from collections import defaultdict
t = defaultdict(int)
ans = 0
for e in s:
	t[e[0]] += 1
for v in t.values():
	if v % 2:
		v1 = v // 2
		v2 = v1 + 1
	else:
		v1 = v2 = v // 2
	if v1 > 1:
		ans += sum(range(v1))
	if v2 > 1:
		ans += sum(range(v2))
print(ans)


import collections
n = int(input())
arr = []
for _ in range(n):
	s = input()
	arr.append(s[0])
c = collections.Counter(arr)
ans = 0
for (key, value) in c.items():
	if value > 1:
		if value % 2 == 0:
			v = value // 2
			a = v * (v - 1) // 2
			ans += a
			ans += a
		else:
			v = value // 2
			a = v * (v - 1) // 2
			ans += a
			b = v * (v + 1) // 2
			ans += b
print(ans)


def my_function(number, result):
	if number <= 1:
		return result
	else:
		return my_function(number - 1, result + number - 1)
n = int(input())
r1 = {}
result = 0
while n > 0:
	name = input()
	if name[0] in r1:
		r1[name[0]] += 1
	else:
		r1[name[0]] = 1
	n -= 1
for v in r1.values():
	if v > 1:
		if v % 2 == 0:
			result += 2 * my_function(v // 2, 0)
		else:
			result += my_function(v // 2, 0) + my_function(v // 2 + 1, 0)
print(result)


def silent_class(n, lst):
	frequency = [0] * 26
	count = 0
	for i in range(n):
		frequency[ord(lst[i][0]) - ord('a')] += 1
	for i in range(len(frequency)):
		if frequency[i] > 2:
			a = frequency[i] // 2
			b = frequency[i] - a
			count += a * (a - 1) // 2 + b * (b - 1) // 2
	return count
m = int(input())
z = list()
for j in range(m):
	s = input()
	z.append(s)
print(silent_class(m, z))


import operator as op
from functools import reduce
import math

def ncr(n, r):
	if n < r:
		return 0
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
dic = {}
n = int(input())
for i in range(0, n):
	x = input()
	if x[0] not in dic:
		dic[x[0]] = 1
	else:
		dic[x[0]] += 1
ans = 0
for key in dic.keys():
	if dic[key] > 2:
		ans += ncr(math.ceil(dic[key] / 2), 2) + ncr(math.floor(dic[key] / 2), 2)
print(int(ans))


n = int(input())
l_1 = []
l_2 = []
d_1 = {}
d_2 = {}
for i in range(n):
	st = str(input())[0]
	if l_1.count(st) <= l_2.count(st):
		l_1.append(st)
	else:
		l_2.append(st)
for i in l_1:
	if not i in d_1:
		d_1[i] = 1
	else:
		d_1[i] += 1
for i in l_2:
	if not i in d_2:
		d_2[i] = 1
	else:
		d_2[i] += 1
k = 0
for i in d_1.values():
	k += i * (i - 1) // 2
for i in d_2.values():
	k += i * (i - 1) // 2
print(k)


def ap(n):
	n -= 1
	return int(n / 2 * (2 + (n - 1)))
n = int(input())
classroom1 = {}
classroom2 = {}
for i in range(n):
	s = input()
	if s[0] in classroom1:
		c1 = classroom1[s[0]]
	else:
		c1 = 0
	if s[0] in classroom2:
		c2 = classroom2[s[0]]
	else:
		c2 = 0
	if c1 > c2:
		if s[0] in classroom2:
			classroom2[s[0]] += 1
		else:
			classroom2[s[0]] = 1
	elif s[0] in classroom1:
		classroom1[s[0]] += 1
	else:
		classroom1[s[0]] = 1
chatting = 0
for c1 in classroom1:
	if classroom1[c1] >= 2:
		chatting += ap(classroom1[c1])
for c2 in classroom2:
	if classroom2[c2] >= 2:
		chatting += ap(classroom2[c2])
print(chatting)


from sys import *
n = int(stdin.readline())
m = []
for i in range(n):
	a = list(input())
	m.append(a)
a = [0] * 26
b = [0] * 26
for i in range(n):
	x = a[ord(m[i][0]) - 97]
	y = b[ord(m[i][0]) - 97]
	if x < y:
		a[ord(m[i][0]) - 97] += 1
	else:
		b[ord(m[i][0]) - 97] += 1
ans = 0
for i in range(26):
	ans += a[i] * (a[i] - 1) // 2
	ans += b[i] * (b[i] - 1) // 2
print(ans)


n = int(input())
name = []
for i in range(n):
	name.append(input())
name.sort()
class1 = name[::2]
class2 = name[1::2]
all1 = ()
z = 1
x = 0
class1.append(' ')
class2.append(' ')
for i in range(1, n // 2 + n % 2 + 1):
	a = list(class1[i])
	b = list(class1[i - 1])
	if a[0] == b[0]:
		z += 1
	else:
		x += z * (z - 1) // 2
		z = 1
z = 1
for i in range(1, n // 2 + 1):
	a = list(class2[i])
	b = list(class2[i - 1])
	if a[0] == b[0]:
		z += 1
	else:
		x += z * (z - 1) // 2
		z = 1
print(x)


from collections import Counter
import math
n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s[0])
d = Counter(l)
count = 0
ans = 0
ans1 = 0
m = sorted(d.values())
for j in m:
	if j > 3:
		if j % 2 == 0:
			t = j // 2
			ans = math.factorial(t) // (2 * math.factorial(t - 2))
			count = count + 2 * ans
		else:
			r = j // 2 + 1
			s = j - r
			ans = math.factorial(r) // (2 * math.factorial(r - 2))
			ans1 = math.factorial(s) // (2 * math.factorial(s - 2))
			count = count + ans + ans1
	elif j == 3:
		count = count + 1
	else:
		count = count + 0
print(count)


from collections import defaultdict

def fatorial(n):
	if n < 2:
		return 1
	return n * fatorial(n - 1)

def comb_p(n, p):
	if n > p:
		return fatorial(n) / (fatorial(p) * fatorial(n - p))
	elif n == p:
		return 1
	else:
		return 0
estudantes = int(input())
letras = defaultdict(int)
for _ in range(estudantes):
	nome = input()
	letras[nome[0]] += 1
grupos_conversa = 0
for (k, v) in letras.items():
	if v > 2:
		metade = int(v / 2)
		grupos_conversa += comb_p(metade, 2)
		grupos_conversa += comb_p(v - metade, 2)
print(int(grupos_conversa))


import math

def f(x):
	return math.floor(x * (x - 1) / 2)
n = input()
n = int(n)
a = [0 for i in range(0, ord('z') + 1)]
for i in range(n):
	s = input()
	a[ord(s[0])] += 1
ans = 0
for i in range(ord('a'), ord('z') + 1):
	l = math.floor(a[i] / 2)
	r = a[i] - l
	ans += f(l)
	ans += f(r)
print(ans)


import math
x = []
for q in range(int(input())):
	x.append(input().strip())
d = {}
for i in x:
	try:
		d[i[0]] += 1
	except KeyError:
		d[i[0]] = 1
x = list(d.values())
res = 0
for i in x:
	xx = math.floor(i / 2)
	y = math.ceil(i / 2)
	res += xx * (xx - 1) // 2 + y * (y - 1) // 2
print(res)


def comb(n, r):
	if n < r:
		return 0
	else:
		return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
import math
n = int(input())
d = {}
cnt = 0
for student in range(n):
	s = input()
	if s[0] in d.keys():
		d[s[0]] += 1
	else:
		d[s[0]] = 1
for val in d.values():
	cnt += comb(math.ceil(val / 2), 2) + comb(math.floor(val / 2), 2)
print(cnt)


n = int(input())
l = [0] * 26
for i in range(n):
	l[ord(input()[0]) - 97] += 1
x = 0
for i in l:
	a = i // 2
	b = i - i // 2
	x += a * (a - 1) // 2 + b * (b - 1) // 2
print(x)


from collections import defaultdict

def nc2(n):
	return n * (n - 1) >> 1
n = int(input())
h = defaultdict(int)
for _ in range(n):
	h[input()[0]] += 1
ans = 0
for v in h.values():
	if v > 2:
		a = v // 2
		b = v - a
		ans += nc2(a) + nc2(b)
print(ans)


n = int(input())
names = []
first_letters = {}
for i in range(n):
	name = input()
	names.append(name)
	if name[0] not in first_letters:
		first_letters[name[0]] = 1
	else:
		first_letters[name[0]] += 1
x = 0
for first_letter in first_letters:
	if first_letters[first_letter] % 2 == 0:
		x += first_letters[first_letter] // 2 * (first_letters[first_letter] // 2 - 1)
	else:
		x += first_letters[first_letter] // 2 * (first_letters[first_letter] // 2 - 1) // 2 + (first_letters[first_letter] // 2 + 1) * (first_letters[first_letter] // 2) // 2
print(x)


from math import factorial

def socitania(n, k):
	if n - k >= 0:
		return factorial(n) // (factorial(k) * factorial(n - k))
	return 0
n = int(input())
x = 0
d = dict()
for i in range(n):
	s = input()[0]
	d[s] = d.get(s, 0) + 1
for (val, key) in d.items():
	if key != 1:
		x += socitania(key // 2, 2) + socitania(key // 2 + key % 2, 2)
print(x)


f = lambda x: x * (x - 1) // 2
n = int(input())
a = [0 for _ in range(26)]
for i in range(n):
	a[ord(input()[0]) - ord('a')] += 1
r = 0
for i in a:
	if i & 1 == 0:
		r += f(i >> 1) << 1
	else:
		r += f(i >> 1) + f((i >> 1) + 1)
print(r)


import math
t = int(input())
d = {}
for i in range(t):
	name = input()
	if name[0] not in d:
		d[name[0]] = 1
	else:
		d[name[0]] = d[name[0]] + 1

def pairs(n):
	return n * (n - 1) / 2
summer = 0
for i in d:
	summer += pairs(math.floor(d[i] / 2)) + pairs(math.ceil(d[i] / 2))
print(int(summer))


from collections import defaultdict
from itertools import combinations
import math

def ncr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
n = int(input())
d = defaultdict(list)
for i in range(n):
	s = input()
	d[s[0]].append(s)
x = 0
for i in d:
	if len(d[i]) > 3:
		g1 = len(d[i]) // 2
		g2 = len(d[i]) - g1
		x = x + ncr(g1, 2) + ncr(g2, 2)
	elif len(d[i]) == 3:
		x = x + 1
print(x)


n = int(input())
name = [None] * n
for i in range(n):
	name[i] = input()
buf = [0] * 26
for i in range(n):
	buf[ord(name[i][0]) - ord('a')] += 1
ans = 0
for i in range(26):
	part1 = buf[i] // 2
	part2 = buf[i] - part1
	ans += part1 * (part1 - 1) / 2 + part2 * (part2 - 1) / 2
print(int(ans))


from math import factorial as f
n = int(input())
l = []
k = []
m = set()
x = 0

def comb(y):
	return f(y) // (2 * f(y - 2))
for i in range(n):
	s = input()
	l.append(s[0])
	m.add(s[0])
for i in m:
	k = l.count(i)
	if k >= 3:
		if k % 2 == 0 and k >= 4:
			x += 2 * comb(k // 2)
		else:
			if k >= 4:
				x += comb(k // 2)
			if k >= 3:
				x += comb(k // 2 + 1)
print(x)


from collections import Counter
import string
n = int(input())
c = Counter()
for i in range(n):
	w = input()
	c[w[0]] += 1

def get_pairs(n):
	return n * (n - 1) // 2
pairs = 0
for letter in string.ascii_lowercase:
	cnt = c[letter]
	first = cnt // 2
	second = cnt - first
	pairs += get_pairs(first) + get_pairs(second)
print(pairs)


def fact(n):
	f = 1
	for i in range(2, n + 1):
		f *= i
	return f
a = []
for i in range(int(input())):
	a.append(input())
letters = {}
for i in a:
	j = i[0]
	if j in letters:
		letters[j] += 1
	else:
		letters[j] = 1
m = 0
mm = True
mmm = 0
for i in letters:
	if letters[i] > 2:
		mm = True
		m = letters[i]
		if m % 2 == 0:
			m = m // 2
			m = int(fact(m) / (2 * fact(m - 2))) * 2
		else:
			m = int(fact(m // 2) / (2 * fact(m // 2 - 2))) + int(fact(m // 2 + 1) / (2 * fact(m // 2 + 1 - 2)))
		mmm += m
if not mm:
	print(0)
else:
	print(mmm)


mapa = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
n = int(input())
for i in range(n):
	seq = str(input())
	mapa[seq[0]] += 1
j = 97
ans = 0
while j <= 122:
	k = chr(j)
	if mapa[k] == 3:
		ans += 1
	elif mapa[k] > 3:
		d = int(mapa[k] / 2)
		x = mapa[k] % 2
		y = d + x
		ans += d * (d - 1) / 2 + y * (y - 1) / 2
	j += 1
print(int(ans))


n = int(input())
d = {}
for i in range(n):
	s = input()
	if d.get(s[0]) == None:
		d[s[0]] = 0
	d[s[0]] += 1
res = 0
for (i, x) in enumerate(d):
	if d[x] > 2:
		y = d[x]
		(d1, d2, m) = (y // 2, y // 2, y % 2)
		if m == 1:
			d2 += 1
		if d1 > 1:
			res += (d1 - 1) * d1 // 2
		if d2 > 1:
			res += (d2 - 1) * d2 // 2
print(res)


t = int(input())
dig = []
for i in range(0, t):
	a = input()
	dig.append(a[0])
from collections import Counter
c = Counter(dig)
sumi = 0
for items in c.values():
	g = items // 2
	h = items - g
	sumi = sumi + g * (g - 1) // 2 + h * (h - 1) // 2
print(sumi)


n = int(input())
arr = []
for u in range(26):
	arr.append(0)
for nn in range(n):
	k = ord(input()[0]) - 97
	arr[k] = arr[k] + 1
x = 0
for mm in range(26):
	if arr[mm] % 2 == 0:
		j = arr[mm] // 2
		x += 2 * (j * (j - 1) / 2)
	else:
		j = arr[mm] // 2
		x += j * (j - 1) / 2 + (j + 1) * j / 2
print(int(x))


import math
n = int(input())
L = {}
max_ = 0
for _ in range(n):
	s = input()
	c = s[0]
	L[c] = L.get(c, 0) + 1
for ch in L.keys():
	c = L[ch]
	y = c // 2
	px = 0
	for x in (y, c - y):
		if x >= 2:
			pairs = math.factorial(x) / (2 * math.factorial(x - 2))
			px += pairs
	max_ += px
print(int(max_))


class SilentClassroom:

	def assign_students(self):
		for i in range(self.student_count):
			self.assign_student(input())
		return self

	def assign_student(self, student_name):
		key = student_name[0]
		if key not in self.classA:
			self.classA[key] = 1
		elif key not in self.classB:
			self.classB[key] = 1
		else:
			self.assign_student_helper(key)

	def assign_student_helper(self, key):
		(countA, countB) = (self.classA[key], self.classB[key])
		if countA <= countB:
			self.classA[key] = countA + 1
		else:
			self.classB[key] = countB + 1

	def determine_pair_count(self):
		keysA = list(self.classA.keys())
		talkA = 0
		for keys in keysA:
			talkA += self.nchoosetwo(self.classA[keys])
		keysB = list(self.classB.keys())
		talkB = 0
		for keys in keysB:
			talkB += self.nchoosetwo(self.classB[keys])
		print(talkA + talkB)

	def nchoosetwo(self, n):
		return round(n * (n - 1) / 2)

	def __init__(self, student_count):
		self.student_count = student_count
		(self.classA, self.classB) = ({}, {})
SilentObj = SilentClassroom(int(input()))
SilentObj.assign_students().determine_pair_count()


def sumat(n):
	return n * (n - 1) // 2
x = int(input())
a = [input()[0] for k in range(x)]
a.sort()
a += ['1']
cont = 1
sumatotal = 0
for k in range(1, x + 1):
	if a[k] == a[k - 1]:
		cont += 1
	else:
		sumatotal += sumat(cont // 2) + sumat(cont // 2 + cont % 2)
		cont = 1
print(sumatotal)


import math
n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x)
c1 = []
c2 = []
d = {}
for i in a:
	if i[0] in d:
		d[i[0]] += 1
	else:
		d[i[0]] = 1
flag = 0
a = sorted(a)
for i in a:
	if flag == 1:
		c2.append(i[0])
		flag = 0
	else:
		flag = 1
		c1.append(i[0])
cc1 = {}
cc2 = {}
for i in c1:
	if i in cc1:
		cc1[i] += 1
	else:
		cc1[i] = 1
for i in c2:
	if i in cc2:
		cc2[i] += 1
	else:
		cc2[i] = 1
res = 0
for i in cc1.keys():
	if cc1[i] > 1:
		p = cc1[i] - 1
		res += int(p * (p + 1) / 2)
for i in cc2.keys():
	if cc2[i] > 1:
		p = cc2[i] - 1
		res += int(p * (p + 1) / 2)
print(res)


n = int(input())
d = {}
for _ in range(n):
	n = input()
	if n[0] not in d:
		d[n[0]] = 1
	else:
		d[n[0]] += 1
c = 0
for i in d:
	if d[i] == 3:
		c += 1
	elif d[i] >= 4:
		if d[i] % 2 == 0:
			x = d[i] // 2
			y = x * (x - 1) // 2
			c += 2 * y
		else:
			x = d[i] // 2
			y = x * (x - 1) // 2
			c += y
			x = d[i] // 2 + 1
			y = x * (x - 1) // 2
			c += y
print(c)


import math

def nCr(n, r):
	if n == 1:
		return 0
	elif n == 2:
		return 1
	else:
		f = math.factorial
		return f(n) // f(r) // f(n - r)
n = int(input())
L = []
ml = {}
for i in range(n):
	temp1 = input()
	temp = temp1[0]
	if temp not in ml:
		ml[temp] = 1
	else:
		ml[temp] += 1
ans = 0
for j in ml:
	m = ml[j]
	if m == 1 or m == 2:
		continue
	elif m % 2 == 0:
		ans += 2 * nCr(m / 2, 2)
	else:
		a = int(m / 2)
		ans += nCr(a, 2) + nCr(m - a, 2)
print(ans)


counter = {}
for i in range(int(input())):
	a = input()[0]
	counter[a] = counter.get(a, 0) + 1
print(int(sum(((n // 2 - 1) * (n // 2) / 2 + ((n + 1) // 2 - 1) * ((n + 1) // 2) / 2 for (c, n) in counter.items()))))


n = int(input())
f = [0] * 26
for i in range(n):
	s = input()
	f[ord(s[0]) - ord('a')] += 1
x = 0
for o in f:
	x += o // 2 * (o // 2 - 1) // 2 + (o // 2 + o % 2) * (o // 2 + o % 2 - 1) // 2
print(x)


n = int(input())
l = []
ans = 0
for i in range(27):
	l.append(0)
for i in range(n):
	s = input()
	x = s[0]
	l[ord(x) - 97] += 1
l.sort(reverse=True)
j = 0
while l[j] > 0:
	a = l[j] // 2
	b = l[j] - a
	for i in range(b):
		ans += i
	for i in range(a):
		ans += i
	j += 1
print(ans)


def sm(n):
	return n * (n - 1) // 2
n = int(input())
(f, c) = ([0] * 26, 0)
for _ in range(n):
	f[ord(input()[0]) - ord('a')] += 1
for i in range(26):
	c += sm(f[i] // 2) + sm(f[i] - f[i] // 2)
print(c)


from collections import Counter
print(sum((n // 2 * (n // 2 - 1) + (n + 1) // 2 * ((n - 1) // 2) for n in Counter((input()[0] for _ in range(int(input())))).values())) // 2)


n = int(input())
dic = {}
for i in range(n):
	line = input()
	if line[0] not in dic:
		dic[line[0]] = 0
	dic[line[0]] += 1
s = 0
for x in dic:
	v = dic[x]
	first = v // 2
	second = v - first
	s += first * (first - 1) / 2
	s += second * (second - 1) / 2
print(int(s))


import math
initials = [0 for _ in range(ord('z') - ord('a') + 1)]
n = int(input())
for _ in range(n):
	initials[ord(input()[0]) - ord('a')] += 1

def permutation_count(n, r):
	if n < r:
		return 0
	return math.factorial(n) / math.factorial(n - r)
print(int(sum(map(lambda i: permutation_count(i // 2, 2) + permutation_count(math.ceil(i / 2), 2), initials)) / 2))


import math
n = int(input())
a = []
b = []
c = []
for i in range(n):
	s = input()
	b.append(s)
for i in b:
	a.append(i[0])
x = list(set(a))
for i in x:
	c.append(a.count(i))
count = 0
for i in c:
	tmp = math.ceil(i / 2)
	tmp1 = math.floor(i / 2)
	count += tmp * (tmp - 1) // 2 + tmp1 * (tmp1 - 1) // 2
print(count)


N = int(input())
dict = {}
for _ in range(N):
	x = input()[0]
	if x in dict:
		dict[x] += 1
	else:
		dict[x] = 1
result = 0
for (k, v) in dict.items():
	a = v // 2
	b = v // 2 + v % 2
	result += a * (a - 1) // 2 + b * (b - 1) // 2
print(result)


import math
n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
ans = 0
b = 'abcdefghijklmnopqrstuvwxyz'
for i in b:
	cnt = 0
	for j in range(n):
		if a[j][0] == i:
			cnt += 1
	o = cnt // 2
	p = cnt - o
	ans += max(0, o * (o - 1) // 2)
	ans += max(0, p * (p - 1) // 2)
print(ans)


n = int(input())
a = {}
S = 0
for i in range(n):
	b = input()
	if b[0] not in a:
		a[b[0]] = 1
	else:
		a[b[0]] += 1
for (key, value) in a.items():
	if value % 2 != 0:
		S += (value // 2) ** 2
	else:
		S += value // 2 * (value // 2 - 1)
print(S)


def par(uch):
	su = (uch - 1) * uch // 2
	return su
n = int(input())
u = []
k = []
for i in range(n):
	name = input()
	b = name[0]
	if b in u:
		for x in range(len(u)):
			if b == u[x]:
				k[x] += 1
	else:
		u.append(b)
		k.append(1)
s = 0
for x in k:
	if x % 2 == 0:
		s += par(x // 2) * 2
	else:
		s += par((x + 1) // 2) + par(x // 2)
print(s)


from collections import Counter
n = int(input())
s = []
for _ in range(n):
	s.append(input()[0])
done = [0] * n
first = []
second = []
r = 0
for cc in Counter(s).most_common():
	if cc[1] > 2:
		t = cc[1]
		p1 = t // 2
		p2 = t - p1
		r += p1 * (p1 - 1) // 2
		r += p2 * (p2 - 1) // 2
print(r)


def summation(i):
	sum = 0
	for i in range(i):
		sum += i
	return sum
a = int(input())
dict_class1 = {}
dict_class2 = {}
general_dict = {}
for i in range(a):
	x = input()
	y = x[0]
	if y in general_dict:
		general_dict[y] += 1
	else:
		general_dict[y] = 1
for i in general_dict:
	if general_dict[i] % 2 == 0:
		dict_class1[i] = general_dict[i] // 2
		dict_class2[i] = general_dict[i] // 2
	else:
		dict_class1[i] = (general_dict[i] - 1) // 2 + 1
		dict_class2[i] = (general_dict[i] - 1) // 2
count = 0
for i in dict_class1:
	count += summation(dict_class1[i])
for i in dict_class2:
	count += summation(dict_class2[i])
print(count)


a = int(input())
r = 0
c = list()
d = list()
f = 0
while r < a:
	b = input()
	c.append(b[0])
	if r == 0:
		d.append(b[0])
	if b[0] not in d:
		d.append(b[0])
	r = r + 1
r = 0
while r < len(d):
	e = c.count(d[r])
	if e % 2 == 0:
		f = f + e // 2 * (e // 2 - 1)
	elif e // 2 == 1:
		f = f + 1
	else:
		f = f + e // 2 * (e // 2)
	r = r + 1
print(f)


D = {}
for _ in range(int(input())):
	x = input()
	if x[0] in D:
		D[x[0]] += 1
	else:
		D[x[0]] = 1
count = 0
for val in D:
	if D[val] > 1:
		X = D[val]
		if X % 2 == 0:
			a = X // 2
			b = X // 2
		else:
			a = X // 2
			b = X // 2 + 1
		a = a * (a - 1) // 2
		b = b * (b - 1) // 2
		count += a + b
print(count)


from math import ceil, floor
n = int(input())
a = [input()[0] for x in range(n)]
from collections import Counter
c = Counter(a)
res = 0
for v in c.values():
	s = ceil(v / 2)
	res += max(0, int(s * (s - 1) / 2))
	s = floor(v / 2)
	res += max(0, int(s * (s - 1) / 2))
print(res)


import math
n = int(input())
l = []
for i in range(n):
	l.append(input())
	l[i] = l[i][0]
r = list(set(l))
s1 = []
s2 = []
tc = 0
for i in range(len(r)):
	x = l.count(r[i])
	y = x // 2
	for j in range(y):
		s1.append(r[i])
	for j in range(x - y):
		s2.append(r[i])
s3 = list(set(s1))
s4 = list(set(s2))
for j in range(len(s3)):
	if s1.count(s3[j]) > 1:
		tc = tc + math.factorial(s1.count(s3[j])) // (2 * math.factorial(s1.count(s3[j]) - 2))
for j in range(len(s4)):
	if s2.count(s4[j]) > 1:
		tc = tc + math.factorial(s2.count(s4[j])) // (2 * math.factorial(s2.count(s4[j]) - 2))
print(tc)


n = int(input())
lis = []
count = 26 * [0]
for i in range(n):
	lis.append(input())
	count[ord(lis[i][0]) - 97] = count[ord(lis[i][0]) - 97] + 1

def hesab(count):
	javab = 0
	for i in range(26):
		if count[i] >= 3:
			if count[i] % 2 == 0:
				javab += count[i] // 2 * (count[i] // 2 - 1)
			if count[i] % 2 == 1:
				javab += (count[i] // 2 * (count[i] // 2 - 1) + (count[i] // 2 + 1) * (count[i] // 2)) // 2
	return javab
print(hesab(count))


import math
n = int(input())
dic = {}
for i in range(n):
	name = input()[0]
	dic[name] = dic.get(name, 0) + 1
cnt = list(dic.values())
comb = 0
for i in cnt:
	k = i // 2
	comb += k * (k - 1) // 2
	k = i - k
	comb += k * (k - 1) // 2
print(comb)


n = int(input())
arr = [0] * 26
for i in range(n):
	s = input()
	x = s[0]
	arr[ord(x) - 97] += 1
su = 0
for x in arr:
	if x == 0 or x == 1:
		continue
	if x % 2 == 0:
		t = x // 2 * (x // 2 - 1)
		su += t
	else:
		t = (x - 1) // 2 * ((x - 1) // 2 - 1) // 2 + (x + 1) // 2 * ((x + 1) // 2 - 1) // 2
		su += t
print(su)


from collections import Counter
s = ''
for _ in range(int(input())):
	name = input()
	s += name[0]
c = Counter(s).values()
pairs = 0
for n in c:
	if n > 2:
		n_min = n // 2
		n_max = n - n_min
		pairs += n_min * (n_min - 1) / 2
		pairs += n_max * (n_max - 1) / 2
print(int(pairs))


def fac(n):
	if n == 0:
		return 1
	return fac(n - 1) * n
n = int(input())
count_pair = 0
dic_name = {}
for _ in range(n):
	name = input()
	if name[0] not in dic_name:
		dic_name[name[0]] = [name]
	else:
		dic_name[name[0]].append(name)
for (key, val) in dic_name.items():
	cnt_name = len(val)
	cnt_name1 = -(-cnt_name // 2)
	cnt_name2 = cnt_name - cnt_name1
	if cnt_name1 >= 2:
		count_pair += fac(cnt_name1) / (2 * fac(cnt_name1 - 2))
	if cnt_name2 >= 2:
		count_pair += fac(cnt_name2) / (2 * fac(cnt_name2 - 2))
print(int(count_pair))


class Problem:

	def __init__(self):
		pass

	def solve(self):
		print(self._solve())

	def _solve(self):
		n = int(input())
		s = []
		for _ in range(n):
			s.append(input().strip())
		d = {}
		for x in s:
			if x[0] not in d:
				d[x[0]] = 1
			else:
				d[x[0]] += 1
		ans = 0
		for x in d:
			o = d[x] // 2
			oo = d[x] - o
			ans += o * (o - 1) // 2 + oo * (oo - 1) // 2
		return ans

def main():
	problem = Problem()
	problem.solve()
main()


a = int(input())
t = []
x = []
for i in range(a):
	b = input()
	t.append(b[0])
x = list(set(t))
tot = 0
for i in range(len(x)):
	s = t.count(x[i])
	if s > 1:
		if s % 2 == 0:
			k = s / 2
			tot += 2 * (k * (k - 1) // 2)
		else:
			k = s // 2
			tot += k * (k - 1) // 2 + k * (k + 1) // 2
print(int(tot))


n = int(input())
names = {}
count = 0
for i in range(n):
	name = input()
	if name[0] not in names:
		names[name[0]] = 1
	else:
		names[name[0]] += 1
for (i, j) in names.items():
	x = j // 2
	y = j - x
	count += x * (x - 1) / 2 + y * (y - 1) / 2
print(int(count))


from operator import mul
from fractions import Fraction
from functools import reduce

def nCk(n, k):
	return int(reduce(mul, (Fraction(n - i, i + 1) for i in range(k)), 1))
n = int(input())
s = []
for i in range(n):
	s.append(input())
d = {}
for name in s:
	c = name[0]
	d[c] = d.get(c, 0) + 1
result = 0
for x in d.values():
	result += nCk(x // 2, 2) + nCk(x - x // 2, 2)
print(result)


n = int(input())
d = {}
for i in range(n):
	s = input()
	c = s[0]
	if not c in d.keys():
		d[c] = 0
	d[c] += 1

def f(a):
	h = a // 2
	j = a - h
	return h * (h - 1) // 2 + j * (j - 1) // 2
print(sum([f(i) for i in d.values()]))


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
from math import *
from decimal import *
from copy import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN(x=' '):
	return map(int, sys.stdin.readline().strip().split(x))

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN():
	return list(numIN())

def dis(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def flush():
	return sys.stdout.flush()

def nc2(n):
	return n * (n - 1) // 2
d = defaultdict(int)
n = int(input())
l = []
for i in range(n):
	l.append(input()[0])
for i in l:
	d[i] += 1
ans = 0
for i in d.values():
	ans += nc2(i // 2) + nc2(i - i // 2)
print(ans)


import math
a = [0] * 26
n = int(input())
for i in range(n):
	s = input().strip()
	a[ord(s[0]) - 97] += 1
count = 0
for i in range(26):
	x = math.ceil(a[i] / 2)
	y = math.floor(a[i] / 2)
	if x > 1:
		count += x * (x - 1) // 2
	if y > 1:
		count += y * (y - 1) // 2
print(count)


from collections import defaultdict

def pairs(n):
	return n * (n - 1) // 2
n = int(input())
names = [input() for _ in range(n)]
letters = defaultdict(int)
for name in names:
	letters[name[0]] += 1
ans = 0
for val in letters.values():
	ans += pairs(val // 2) + pairs(val - val // 2)
print(ans)


n = int(input())
names = {}
for i in range(n):
	first_letter = input()[0]
	names[first_letter] = names.get(first_letter, 0) + 1
res = 0
for (key, val) in names.items():
	(a, b) = (val // 2, val - val // 2)
	res += a * (a - 1) / 2 + b * (b - 1) / 2
print(int(res))


n = int(input())
a = []
f = dict()
for i in range(n):
	x = input()
	a.append(x)
	if x[0] in f:
		f[x[0]] += 1
	else:
		f[x[0]] = 1
res = 0
for (k, v) in f.items():
	if v > 1:
		if v % 2:
			l = v // 2
			r = v - l
			res += l * (l - 1) // 2 + r * (r - 1) // 2
		else:
			l = v // 2
			r = v - l
			res += l * (l - 1) // 2 + r * (r - 1) // 2
print(res)


n = int(input())
d = {}

def nChoose2(x):
	return x * (x - 1) / 2
for i in range(n):
	a = input()[0]
	d[a] = d.get(a, 0) + 1
count = 0
for letter in d:
	if d[letter] != 0:
		if d[letter] % 2 == 1:
			count += nChoose2(d[letter] // 2 + 1) + nChoose2(d[letter] // 2)
		else:
			count += 2 * nChoose2(d[letter] / 2)
print(int(count))


n = int(input())
ans = 0
cn = [0 for i in range(26)]
for i in range(n):
	c = str(input())
	cn[ord(c[0]) - ord('a')] += 1
for i in range(26):
	nb = cn[i] // 2
	nbb = cn[i] - nb
	ans += nb * (nb - 1) // 2 + nbb * (nbb - 1) // 2
print(ans)


import math
n = int(input())
(list, s, res) = ([], 'abcdefghijklmnopqrstuvwxyz', 0)
for i in range(n):
	list.append(input())
for ch in s:
	cnt = 0
	for i in range(n):
		if list[i][0] == ch:
			cnt += 1
	(l, r) = (int(math.ceil(cnt / 2)), int(math.floor(cnt / 2)))
	res += int(l * (l - 1) / 2) + int(r * (r - 1) / 2)
print(res)


from collections import defaultdict
n = int(input())
dic = defaultdict(lambda : 0)
for i in range(n):
	s = input()
	dic[s[0]] += 1
ans = 0
for i in dic.values():
	j = i // 2
	i -= j
	ans += i * (i - 1) + j * (j - 1)
print(ans // 2)


import math
n = int(input())
L = [0] * 26
for i in range(n):
	s = input()
	o = ord(s[0]) - 97
	L[o] += 1
res = 0
first = []
second = []
for i in range(26):
	if L[i] > 1:
		first.append(int(L[i] / 2))
		second.append(int(L[i] / 2) if L[i] % 2 == 0 else int(L[i] / 2) + 1)
for e in first:
	if e > 1:
		res += e * (e - 1) / 2
for e in second:
	if e > 1:
		res += e * (e - 1) / 2
print(int(res))


n = int(input())
a = []
for i in range(n):
	a.append(input())
a = sorted(a)
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		if i % 2 == j % 2 and a[i][0] == a[j][0]:
			ans += 1
print(ans)


n = int(input())
_e = [0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950]
groups = {}
c = 0
for i in range(n):
	s = input()[0]
	if s in groups:
		groups[s] += 1
	else:
		groups[s] = 1
for k in groups.keys():
	_ = groups[k]
	if _ % 2 == 0:
		c += _e[_ // 2] * 2
	else:
		c += _e[_ // 2] + _e[_ // 2 + 1]
print(c)


from collections import Counter
import math
n = int(input())
s = []
for i in range(n):
	s.append(input()[0])
c = dict(Counter(s))
ans = 0
for (key, value) in c.items():
	a = math.floor(value / 2)
	b = math.ceil(value / 2)
	ans += a * (a - 1) / 2
	ans += b * (b - 1) / 2
print(int(ans))


from sys import stdin, stdout
from math import *

def main():
	n = int(stdin.readline())
	cnt = [0] * 28
	for i in range(n):
		s = stdin.readline().strip()
		cnt[ord(s[0]) - ord('a')] += 1
	res = 0
	n_pair = lambda x: int(x * (x - 1) / 2)
	for t in cnt:
		if t > 1:
			x1 = int(t / 2)
			x2 = t - x1
			res += n_pair(x1) + n_pair(x2)
	stdout.write(str(res))
	return 0
main()


def contP(n):
	c = 2
	tot = 1
	while c != n:
		tot = tot + c
		c += 1
	return tot
d = {}
for _ in range(int(input())):
	s = input()
	d[s[0]] = d.get(s[0], 0) + 1
result = 0
for i in d:
	if d[i] > 1:
		tmp = d[i] // 2
		if tmp == 1 and d[i] - tmp != tmp:
			result += 1
		elif tmp != 1:
			result += contP(tmp) + contP(d[i] - tmp)
print(result)


import sys
import math
from collections import Counter
input = sys.stdin.readline

def inp():
	return int(input())

def inps():
	return str(input())

def inlt():
	return list(map(int, input().split()))

def inlst():
	return list(map(str, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def pairs(n):
	n1 = math.floor(n / 2)
	n2 = n - n1
	return n1 * (n1 - 1) / 2 + n2 * (n2 - 1) / 2
n = inp()
names = []
for i in range(n):
	names.append(inps()[0])
counts = Counter(names).values()
val = 0
for i in counts:
	val += pairs(i)
print(int(val))


import math

def nCr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
t = int(input())
names = []
for i in range(t):
	names.append(input())
names = list(map(lambda n: n[0], names))
c1 = []
c2 = []
(n1, n2) = (0, 0)
for i in names:
	if c1.count(i) == 0:
		c1.append(i)
	elif c2.count(i) == 0:
		c2.append(i)
	else:
		c1.append(i)
		n1 = nCr(c1.count(i), 2)
		c1.pop(-1)
		c2.append(i)
		n2 = nCr(c2.count(i), 2)
		c2.pop(-1)
		if n1 < n2:
			c1.append(i)
		else:
			c2.append(i)
x = 0
s = set(c1)
for i in s:
	ct = c1.count(i)
	if ct != 1:
		x += nCr(ct, 2)
s = set(c2)
for i in s:
	ct = c2.count(i)
	if ct != 1:
		x += nCr(ct, 2)
print(int(x))


n = int(input())
D = [0] * 26
for i in range(n):
	s = input()
	D[ord(s[0]) - ord('a')] += 1
num = 0
for i in range(26):
	k = D[i] // 2
	l = D[i] - k
	num += (k - 1) * k // 2
	num += l * (l - 1) // 2
print(num)


from math import *
n = int(input())
alpha = [0] * 26
for i in range(n):
	s = input()
	alpha[ord(s[0]) - ord('a')] += 1
pairs = 0
for i in range(26):
	if alpha[i] > 2:
		k = alpha[i] / 2
		pairs += sum(list(range(1, floor(k)))) + sum(list(range(1, ceil(k))))
print(pairs)


n = int(input())
a = [0 for _ in range(26)]
for _ in range(n):
	name = input()
	a[ord(name[0]) - ord('a')] += 1
t = 0
for m in a:
	l1 = m // 2
	l2 = m - l1
	t += l1 * (l1 - 1) // 2
	t += l2 * (l2 - 1) // 2
print(t)


import math

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
n = int(input())
c1 = []
c2 = []
for i in range(n):
	s = input()
	if c1.count(s[0]) < c2.count(s[0]):
		c1.append(s[0])
	else:
		c2.append(s[0])
ct = 0
for i in c1:
	a = c1.count(i)
	if a >= 2:
		ct += nCr(a, 2)
	c1 = list(filter(lambda a: a != i, c1))
for i in c2:
	a = c2.count(i)
	if a >= 2:
		ct += nCr(a, 2)
	c2 = list(filter(lambda a: a != i, c2))
print(ct)


from sys import stdin, stdout

def input():
	return stdin.readline()[:-1]
memo = [-1] * 10 ** 5
memo[0] = 1

def fact(k):
	if memo[k] == -1:
		memo[k] = k * fact(k - 1)
	return memo[k]

def comb(n, k=2):
	if k == 2:
		return n * (n - 1) // 2
	return fact(n) / (fact(n - k) * fact(k))
n = int(input())
dic = {}
for i in range(n):
	name = input()
	if name[0] in dic:
		dic[name[0]] += 1
	else:
		dic[name[0]] = 1
x = 0
for i in dic.values():
	x += comb(i // 2) + comb(i - i // 2)
print(x)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
names = []
for i in range(n):
	names.append(input())
alphabets = [0 for x in range(26)]
for name in names:
	alphabets[ord(name[0]) - ord('a')] += 1
res = 0
for i in range(26):
	if alphabets[i] > 1:
		temp1 = alphabets[i] // 2
		temp2 = alphabets[i] - alphabets[i] // 2
		if temp1 > 1:
			res = res + ncr(temp1, 2)
		if temp2 > 1:
			res = res + ncr(temp2, 2)
print(int(res))


import math
n = int(input())
alpha = 26
count = 0
arr = [0] * alpha
while n > 0:
	st = input()
	y = ord(st[0])
	arr[y - 97] = arr[y - 97] + 1
	n = n - 1
arr.sort(reverse=True)
i = 0
while i < 26:
	if arr[i] > 1:
		p1 = int(arr[i] / 2)
		p2 = arr[i] - p1
		if p1 > 1:
			e = math.factorial(p1) / (2 * math.factorial(p1 - 2))
			count = count + e
		if p2 > 1:
			e1 = math.factorial(p2) / (2 * math.factorial(p2 - 2))
			count = count + e1
	if arr[i] == 0:
		break
	if arr[i] == 1:
		break
	i = i + 1
print(int(count))


n = int(input())
count = [0] * 26
for _ in range(n):
	count[ord(input()[0]) - ord('a')] += 1
ans = 0

def nc2(n):
	return n * (n - 1) / 2
for i in range(26):
	ans += nc2(count[i] // 2) + nc2(count[i] - count[i] // 2)
print(int(ans))


n = int(input())
mat = [0] * 26
for _ in range(n):
	s = input()
	mat[ord(s[0]) - 97] += 1
res = 0
for x in mat:
	lx = x // 2
	res += lx ** 2
	if x % 2 == 0:
		res -= lx
print(res)


n = int(input())

def fact(num):
	res = 1
	for i in range(2, num + 1):
		res = res * i
	return res
count = []
for i in range(27):
	count.append(0)
for i in range(n):
	s = input()
	s = s[0]
	count[ord(s) - 96] += 1
ans = 0
for i in range(1, 27):
	a = count[i]
	b = a - a // 2
	a = a - b
	ans = ans + fact(a) // (fact(2) * fact(a - 2)) + fact(b) // (fact(2) * fact(b - 2))
print(ans)


n = int(input())
a = list()
for i in range(n):
	a.append(input().strip())
a.sort()
x = 0
i = 0
while i < n:
	t = 0
	tm = a[i][0]
	while a[i][0] == tm:
		i += 1
		t += 1
		if i == n:
			break
	if t % 2 == 0:
		n1 = t // 2
		x += n1 * (n1 - 1)
	else:
		n1 = t // 2
		n2 = n1 + 1
		x += n1 * (n1 - 1) // 2
		x += n2 * (n2 - 1) // 2
print(x)


n = int(input())
S = [0] * 26
for i in range(n):
	S[ord(input()[0]) - 97] += 1
ANS = 0
for s in S:
	u = s // 2
	t = s - u
	ANS += u * (u - 1) // 2 + t * (t - 1) // 2
print(ANS)


n = int(input())
names = []
for i in range(n):
	names.append(input()[0])
from collections import *
cnt = Counter(names)
res = 0

def permu(a):
	return a * (a - 1) // 2
for (k, v) in cnt.items():
	if v % 2 == 0:
		res += permu(v // 2) * 2
	else:
		res += permu(v // 2) + permu(v // 2 + 1)
print(res)


n = int(input())
a = ''
res = 0

def fact(n):
	x = 1
	for i in range(1, n + 1):
		x *= i
	return x
for i in range(n):
	a += input()[0]
b = set(a)
for i in b:
	c = a.count(i)
	count1 = count2 = 0
	if c > 2:
		students1 = c // 2
		students2 = c - students1
		if students1 >= 2:
			count1 = fact(students1) / fact(students1 - 2) / 2
		if students2 >= 2:
			count2 = fact(students2) / fact(students2 - 2) / 2
		res += count1 + count2
print(int(res))


from collections import defaultdict
n = int(input())
x = defaultdict(int)
for i in range(n):
	s = input()
	x[s[0]] += 1
sol = 0
for i in x:
	a = x[i] // 2
	b = x[i] - a
	sol += a * (a - 1) // 2
	sol += b * (b - 1) // 2
print(sol)


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
from collections import defaultdict
n = iin()
a = [input() for i in range(n)]
a.sort()
sol = defaultdict(int)
sol1 = defaultdict(int)
ch = 0
i = 0
while i < n:
	ch1 = a[i][0]
	ch2 = 0
	while i < n and a[i][0] == ch1:
		if ch2 % 2:
			sol[a[i][0]] += 1
		else:
			sol1[a[i][0]] += 1
		ch2 += 1
		i += 1
for i in sol1:
	ch += sol1[i] * (sol1[i] - 1) // 2
for i in sol:
	ch += sol[i] * (sol[i] - 1) // 2
print(ch)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from string import *
s = ascii_lowercase
l = [0] * 26
n = ii()
for i in range(n):
	s1 = si()
	l[s.index(s1[0])] += 1
c = 0
(x, y) = (0, 0)
for i in l:
	if i & 1:
		x = i // 2
		y = i // 2 + 1
	else:
		x = i // 2
		y = i // 2
	c += x * (x - 1) // 2 + y * (y - 1) // 2
print(c)


import math
inp = lambda cast=int: list(map(cast, input().split()))
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
(n,) = inp()
A = {}
for _ in range(n):
	(s,) = inp(str)
	A[s[0]] = A.get(s[0], 0) + 1
res = 0
for a in A:
	x = math.ceil(A[a] / 2)
	res += x * (x - 1) // 2
	x = A[a] - x
	res += x * (x - 1) // 2
print(res)


N = int(input())
X = [0] * 26

def stoi(s):
	return ord(s) - 97
for i in range(N):
	s = input()
	X[stoi(s[0])] += 1
ans = 0
for x in X:
	a = x // 2
	b = x - a
	ans += a * (a - 1) + b * (b - 1)
print(ans // 2)


n = int(input())
(l1, l2) = ([], [])
cp = 0
for i in range(n):
	x = input()
	x = x[0]
	c1 = l1.count(x)
	c2 = l2.count(x)
	if c1 < c2:
		l1.append(x)
		cp = cp + c1
	else:
		l2.append(x)
		cp = cp + c2
print(cp)


l = [0] * 26
for _ in range(int(input())):
	s = input()
	l[ord(s[0]) - ord('a')] += 1
f = 0
for i in l:
	x = i // 2
	y = i - x
	f += x * (x - 1) // 2
	f += y * (y - 1) // 2
print(f)


n = int(input())
a = [input() for i in range(n)]
alph = 'abcdefghijklmnopqrstuvwxyz'
memo = {}

def combination(n, r):
	r = min(r, n - r)
	result = 1
	for i in range(n - r + 1, n + 1):
		result *= i
	for i in range(1, r + 1):
		result //= i
	return result
for i in range(n):
	for j in alph:
		if a[i][0] == j:
			if j not in memo:
				memo[j] = 1
			else:
				memo[j] += 1
ans = 0
for i in alph:
	if i in memo:
		tmp = memo[i] // 2
		tmp2 = memo[i] - tmp
		if tmp >= 2:
			ans += combination(tmp, 2)
		if tmp2 >= 2:
			ans += combination(tmp2, 2)
print(ans)


from collections import defaultdict
arr = []
for _ in range(int(input())):
	arr.append(input()[0])
arr.sort()
st1 = defaultdict(int)
st2 = defaultdict(int)
for i in arr:
	if st1[i] <= st2[i]:
		st1[i] += 1
	else:
		st2[i] += 1
x = 0
for i in st1.values():
	x += i * (i - 1) // 2
for i in st2.values():
	x += i * (i - 1) // 2
print(x)


n = int(input())
c1 = []
c2 = []
E = 0
for i in range(n):
	f = str(input())
	f = f[0]
	if c1.count(f) <= c2.count(f):
		c1.append(f)
	else:
		c2.append(f)
c1_s = list(set(c1))
c2_s = list(set(c2))
for i in range(len(c1_s)):
	k = c1.count(c1_s[i])
	E += k * (k - 1) // 2
for i in range(len(c2_s)):
	k = c2.count(c2_s[i])
	E += k * (k - 1) // 2
print(E)


amount = int(input())
name = dict()
keys = set()
for i in range(amount):
	current = input()[0]
	if current in keys:
		name[current] += 1
	else:
		name[current] = 1
		keys.add(current)
ans = 0
for elem in keys:
	current = name[elem] // 2
	ans += current * (current - 1) // 2
	current = name[elem] - current
	ans += current * (current - 1) // 2
print(ans)


name = 'abcdefghijklmnopqrstuvwxyz'
mapping = {}
for (i, char) in enumerate(name):
	mapping[char] = i
n = int(input())
count = [0] * 26
for _ in range(n):
	name = input()
	count[mapping[name[0]]] += 1
ans = 0
for i in count:
	ans += i // 2 * (i // 2 - 1) // 2
	ans += (i // 2 + i % 2) * (i // 2 + i % 2 - 1) // 2
print(ans)


from collections import *
n = int(input())
l = []
for i in range(n):
	y = input()
	l.append(y[0])
f = Counter(l)
e = list(f.values())
add = 0
for i in range(len(e)):
	if e[i] > 2:
		if e[i] == 3:
			add += 1
		elif e[i] == 4:
			add += 2
		elif e[i] % 2 == 0:
			q = e[i] // 2
			add += q * (q - 1)
		elif e[i] % 2 == 1:
			q = e[i] // 2 + 1
			cv = e[i] - q
			add += (q * (q - 1) + cv * (cv - 1)) // 2
print(add)


def cn2(x):
	result = x * (x - 1) / 2
	return int(result)
n = int(input())
l = []
d = {}
count = 0
for i in range(n):
	a = input()
	if a[0] in l:
		d[a[0]] += 1
	else:
		l.append(a[0])
		d[a[0]] = 1
for value in d.values():
	count += cn2(value // 2) + cn2(value - value // 2)
print(count)


n = int(input())
a = [0] * 27
for i in range(n):
	s = input()
	a[ord(s[0]) - 97] += 1
x = 0
for elem in a:
	if elem > 2 and elem % 2 == 0:
		x += elem // 2 * (elem // 2 - 1)
	elif elem > 2 and elem % 2 == 1:
		x += elem // 2 * (elem // 2 - 1) // 2 + elem // 2 * (elem // 2 + 1) // 2
print(int(x))


def meth(n, r):
	if n == 1:
		return 0
	else:
		return n * (n - 1) // 2
t = int(input())
a = [0] * 26
b = []
for i in range(t):
	b.append(input())
for x in b:
	a[ord(x[0]) - 97] += 1
val = 0
for i in range(26):
	if a[i] % 2 == 0:
		val += 2 * meth(a[i] // 2, 2)
	else:
		val += meth(a[i] // 2, 2) + meth(a[i] - a[i] // 2, 2)
print(val)


seq = lambda : list(map(int, input().strip().split()))
inp = lambda : int(input())
mul = lambda : map(int, input().strip().split())
from collections import defaultdict as dd
n = inp()
d = dd(int)
for i in range(n):
	s = input().strip()
	d[s[0]] += 1
ct = 0
for i in d:
	if d[i] > 1:
		q = d[i] // 2
		q1 = d[i] - q
		ct += q * (q - 1) // 2 + q1 * (q1 - 1) // 2
print(ct)


import string
n = int(input())
cnt = {x: 0 for x in string.ascii_lowercase}
for i in range(n):
	cnt[input()[0]] += 1
print(sum([x // 2 * (x // 2 - 1) // 2 + (x - x // 2) * (x - x // 2 - 1) // 2 for x in list(cnt.values()) if x > 2]))


d = dict()

def fact(n):
	if n <= 0:
		return 1
	return n * fact(n - 1)
n = int(input())
for i in range(n):
	x = input()[0]
	if x in d:
		d[x] = d[x] + 1
	else:
		d[x] = 1
l = sorted(d.values(), reverse=True)
sum = 0
for i in l:
	if i <= 1:
		break
	else:
		sum += 2 * (fact(i // 2) // (2 * fact(i // 2 - 2)))
		if i > 2 and i % 2 == 1:
			sum += i // 2
print(sum)


from collections import Counter
from itertools import combinations
import math
n = int(input())
l = list()
p = 0
for i in range(0, n):
	x = str(input())
	l.append(x[0])
if n == 1 or n == 2:
	print(0)
else:
	r = dict(Counter(l))
	fl = 0
	for (i, j) in r.items():
		if j > 1:
			fl = 1
			if j > 2 and j % 2 == 0:
				j = j // 2
				p = p + j * (j - 1)
			else:
				i = j // 2
				k = j - i
				p = p + i * (i - 1) // 2 + k * (k - 1) // 2
	if fl == 0:
		print(0)
	else:
		print(p)


from itertools import combinations
n = int(input(''))
names = []
for i in range(n):
	names.append(str(input('')))
names = sorted(names)
diction = {}
for i in range(n):
	if names[i][0] not in diction:
		diction[names[i][0]] = 1
	else:
		diction[names[i][0]] += 1
pairs = 0
for key in diction:
	if diction[key] % 2 == 0:
		x = int(diction[key])
		pup = [int(i) for i in range(int(x / 2))]
		comb = combinations(pup, 2)
		pairs = pairs + len(list(comb)) * 2
	else:
		x = int(diction[key])
		pup = [int(i) for i in range(int(x / 2))]
		comb = combinations(pup, 2)
		pairs = pairs + len(list(comb))
		pup = [int(i) for i in range(int(x / 2) + 1)]
		comb = combinations(pup, 2)
		pairs = pairs + len(list(comb))
print(pairs)


import math

def nCr(n, r):
	if n < r:
		return 0
	f = math.factorial
	return f(n) / f(r) / f(n - r)

def main():
	A = [0] * 26
	res = 0
	nonames = int(input())
	for i in range(nonames):
		s = input()
		a = ord(s[0]) - 97
		A[a] = A[a] + 1
	for j in range(26):
		if A[j] % 2 == 0:
			res = res + 2 * nCr(A[j] / 2, 2)
		else:
			res = res + nCr((A[j] - 1) / 2, 2)
			res = res + nCr((A[j] + 1) / 2, 2)
	print(round(res))
main()


n = int(input())
dic = {}
ans = 0
for i in range(0, n):
	s = str(input())
	if s[0] in dic:
		dic[s[0]] += 1
	else:
		dic[s[0]] = 1
for i in dic:
	if dic[i] >= 2:
		if dic[i] % 2 == 0:
			ans += dic[i] * (dic[i] // 2 - 1) // 2
		else:
			ans += (dic[i] + 1) // 2 * ((dic[i] + 1) // 2 - 1) // 2 + (dic[i] - 1) // 2 * ((dic[i] - 1) // 2 - 1) // 2
print(ans)


N = int(input())
dic = {}
for _ in range(N):
	s = input()[0]
	if not s in dic.keys():
		dic[s] = 1
	else:
		dic[s] += 1
ans = 0
for v in dic.values():
	a1 = v // 2
	a2 = v - a1
	ans += a1 * (a1 - 1) // 2 + a2 * (a2 - 1) // 2
print(ans)


import math
import itertools as it
from collections import Counter as co

def com(n):
	a = math.factorial(n) / math.factorial(2)
	a = a / math.factorial(n - 2)
	return int(a)
l1 = {}
c1 = 0
l2 = {}
c2 = 0
ss = []
for _ in range(int(input())):
	s = input()
	ss.append(s[0])
ss = sorted(ss)
coo = co(ss)
for let in coo.keys():
	while coo[let] != 0:
		if c1 <= c2:
			if let not in l1:
				l1[let] = 1
				coo[let] -= 1
			elif let not in l2:
				l2[let] = 1
				coo[let] -= 1
			elif l1[let] == 1:
				l1[let] += 1
				c1 += 1
				coo[let] -= 1
			elif l2[let] == 1:
				l2[let] += 1
				c2 += 1
				coo[let] -= 1
			else:
				l1[let] += 1
				c1 -= com(l1[let] - 1)
				c1 += com(l1[let])
				coo[let] -= 1
		elif let not in l1:
			l1[let] = 1
			coo[let] -= 1
		elif let not in l2:
			l2[let] = 1
			coo[let] -= 1
		elif l1[let] == 1:
			l1[let] += 1
			c1 += 1
			coo[let] -= 1
		elif l2[let] == 1:
			l2[let] += 1
			c2 += 1
			coo[let] -= 1
		else:
			l2[let] += 1
			c2 -= com(l2[let] - 1)
			c2 += com(l2[let])
			coo[let] -= 1
print(c1 + c2)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

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

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def solve():
	t = 1
	for _ in range(t):
		n = nu()
		f = [0] * 26
		cc = 0
		for i in range(n):
			a = input()
			gp = ord(a[0]) - ord('a')
			f[gp] += 1
		for i in range(26):
			if f[i] % 2 == 0:
				pq = f[i] // 2
				cc += pq * (pq - 1)
			else:
				gg = f[i] // 2
				hh = gg + 1
				cc += gg * (gg - 1) // 2
				cc += hh * (hh - 1) // 2
		print(cc)
solve()


n = int(input())
lst = []
for i in range(n):
	s = input()
	lst.append(s[0])
lst2 = []
ls = []
for i in range(n):
	if lst[i] not in ls:
		ls.append(lst[i])
		f = lst.count(lst[i])
		lst2.append(f)
l = len(lst2)
c = 0
for i in range(l):
	if lst2[i] > 2:
		p = lst2[i] // 2
		if lst2[i] % 2 == 0:
			c += p * (p - 1)
		else:
			c += p * (p - 1) // 2 + (p + 1) * p // 2
print(c)


def f(n):
	return n * (n - 1) // 2
n = int(input())
dictionary = {chr(t): 0 for t in range(97, 123)}
for _ in range(n):
	dictionary[input()[0]] += 1
s = 0
for k in dictionary:
	r = dictionary[k]
	if r == 0:
		s += 0
	if r == 1:
		s += 0
	else:
		x = r // 2
		y = r - x
		s += f(x)
		s += f(y)
print(s)


def com(x):
	output = output = 0
	for i in range(x):
		output += i
	return output
n = int(input())
a = [0] * 26
result = 0
for i in range(n):
	s = input()
	a[ord(s[0]) - 97] += 1
for i in range(26):
	result += com(int(a[i] / 2)) + com(int(a[i] / 2) + a[i] % 2)
print(result)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	c = collections.Counter([S()[0] for _ in range(n)])
	r = 0
	for v in c.values():
		t = v // 2
		u = v - t
		r += t * (t - 1) // 2
		r += u * (u - 1) // 2
	return r
print(main())


t = int(input())
a = {}
while t > 0:
	s = input()[0]
	if s in a:
		a[s] += 1
	else:
		a[s] = 1
	t -= 1
count = 0
for x in a.keys():
	y = a[x] // 2
	z = y + a[x] % 2
	count += y * (y - 1) // 2
	count += z * (z - 1) // 2
print(count)


def pairs(n):
	if n <= 1:
		return 0
	else:
		return n * (n - 1) // 2
n = int(input())
letters = [0 for i in range(26)]
for _ in range(n):
	c = input()[0]
	letters[ord(c) - 97] += 1
ans = 0
for i in range(26):
	if letters[i] > 2:
		if letters[i] % 2 == 0:
			ans += 2 * pairs(letters[i] // 2)
		else:
			ans += pairs(letters[i] // 2) + pairs(letters[i] // 2 + 1)
print(ans)


n = int(input())
A = [''] * n
for i in range(0, n):
	s = input()
	A[i] = s[0]
a = [0] * 26
for k in A:
	a[ord(k) - ord('a')] += 1
x = 0
for m in a:
	x1 = x2 = 0
	x1 = m // 2
	x2 = m - x1
	if x1 == 0 or x1 == 1:
		x1 = 0
	else:
		x1 = x1 * (x1 - 1) // 2
	if x2 == 0 or x2 == 1:
		x2 = 0
	else:
		x2 = x2 * (x2 - 1) // 2
	x += x1 + x2
print(x)


import collections

def cal(n):
	return n * (n - 1) // 2
n = int(input())
l = []
for i in range(n):
	l.append(input()[0])
	d = collections.Counter(l)
count = 0
for i in d:
	if d[i] % 2 == 0:
		count += cal(d[i] // 2)
		count += cal(d[i] // 2)
	else:
		count += cal((d[i] - 1) // 2)
		count += cal((d[i] + 1) // 2)
print(count)


n = int(input().strip())
chars = dict()
while n > 0:
	s = input()
	chars[s[0:1]] = chars.get(s[0:1], 0) + 1
	n -= 1
ans = 0
for (k, v) in chars.items():
	if v & 1:
		a = v // 2
		b = v - a
		ans += (a * (a - 1) + b * (b - 1)) // 2
	else:
		a = v // 2
		ans += a * (a - 1)
print(ans)


a = int(input())
l = []
for i in range(0, a):
	str1 = input()
	l.append(str1)
l2 = []
for i in range(0, 26):
	l2.append(0)
for i in range(0, a):
	x = ord(l[i][0])
	x = x - 97
	l2[x] += 1
pairs = 0
for i in range(0, 26):
	if l2[i] > 1:
		y = int(l2[i] / 2)
		add1 = int(y * (y - 1) / 2)
		y1 = l2[i] - y
		add2 = int(y1 * (y1 - 1) / 2)
		pairs = pairs + add1 + add2
print(pairs)


from itertools import groupby
import sys
import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
Lines = []
for Line in sys.stdin:
	Lines.append(Line.rstrip('\n'))
n = Lines[0]
n = int(n)
del Lines[0]
names = []
initials = []
for i in range(n):
	names += [Lines[i]]
	initials += [Lines[i][0]]
initials = sorted([list(j) for (i, j) in groupby(sorted(initials))], key=len)
A = []
B = []
for I in initials:
	if len(I) == 1:
		A += [I]
	else:
		c = len(I) // 2
		H = []
		for i in range(c):
			H += [I[0]]
		A += [H]
		H = []
		for i in range(len(I) - c):
			H += [I[0]]
		B += [H]
counter = 0
for I in A:
	if len(I) >= 2:
		counter += ncr(len(I), 2)
for I in B:
	if len(I) >= 2:
		counter += ncr(len(I), 2)
print(int(counter))


nr = [0, 0]
last = '00'
x = alt = 0
n = int(input())
a = [input()]
for i in range(n - 1):
	a.append(input())
a.sort()
a.append('00')
for s in a:
	alt ^= 1
	if s[0] == last[0]:
		nr[alt] += 1
	else:
		x += nr[0] * (nr[0] - 1) / 2 + nr[1] * (nr[1] - 1) / 2
		last = s
		nr = [0, 0]
		nr[alt] += 1
print(int(x))


def s(x):
	if x == 0:
		return 0
	return x * (x - 1) // 2
n = int(input())
a = [input() for k in range(n)]
a.sort(key=lambda x: x[0])
f = '?'
sss = 0
sus = 0
for k in a:
	if k[0] != f:
		e = sss // 2
		t = sss - e
		sus += s(e) + s(t)
		sss = 1
		f = k[0]
	else:
		sss += 1
e = sss // 2
t = sss - e
sus += s(e) + s(t)
print(sus)


from collections import defaultdict
N = int(input())
students = [input() for _ in range(N)]
names = defaultdict(int)
ans = 0
for n in students:
	names[n[0]] += 1
for i in names.values():
	if i == 3:
		ans += 1
	elif i > 3:
		rd = i // 2
		ru = -(-i // 2)
		ans += rd * (rd - 1) // 2
		ans += ru * (ru - 1) // 2
print(ans)


N = int(input())

def letters():
	for code in range(ord('a'), ord('z') + 1):
		yield chr(code)
A = {x: 0 for x in letters()}
for i in range(N):
	name = input()
	A[name[0]] += 1
B = [0]
for i in range(100):
	last = B[-1] + i
	B.append(last)
ans = 0
for x in letters():
	size_B = (A[x] + 1) // 2
	size_A = A[x] - size_B
	ans += B[size_A] + B[size_B]
print(ans)


def get_int():
	from sys import stdin
	return int(stdin.readline().replace('\n', ''))

def get_int_list():
	from sys import stdin
	return [int(x) for x in stdin.readline().replace('\n', '').split(' ')]

def get_str():
	from sys import stdin
	return stdin.readline().replace('\n', '')

def factorial(n):
	return partial_factorial(n, 0)

def partial_factorial(n, m):
	fac = 1
	for i in range(m + 1, n + 1):
		fac *= i
	return fac

def combination(n, m):
	if n < m:
		return 0
	return int(partial_factorial(n, m) // factorial(n - m))

def min_chatty_pairs(names):
	_min = 10000000000.0 + 7
	for i in range(len(names)):
		room_a = i
		room_b = len(names) - i
		if room_b >= room_a:
			comb = combination(room_a, 2) + combination(room_b, 2)
			if comb < _min:
				_min = comb
	return _min

def chatty(names, n):
	n_pairs = 0
	for letter in names:
		if len(names[letter]) != 1:
			n_pairs += min_chatty_pairs(names[letter])
	return n_pairs
n = get_int()
names = dict()
for i in range(n):
	name = get_str()
	if name[0] in names:
		names[name[0]] += [name]
	else:
		names[name[0]] = [name]
print(chatty(names, n))


def pair(n):
	return n * (n - 1) // 2
N = int(input())
cnt = [0] * 26
for i in range(N):
	cnt[ord(input()[0]) - ord('a')] += 1
ret = 0
for i in range(26):
	ret += pair(cnt[i] // 2)
	ret += pair((cnt[i] + 1) // 2)
print(ret)


n = int(input())
arr = []
for i in range(n):
	arr.append(str(input()))
arr.sort()
count = 0
i = 0
curcount = 1
while i < n:
	if i + 1 < n and arr[i][0] == arr[i + 1][0]:
		curcount += 1
		i += 1
		continue
	else:
		if curcount % 2 == 0:
			x = curcount // 2
			y = curcount // 2
			count += x * (x - 1) // 2 + y * (y - 1) // 2
		else:
			x = curcount // 2 + 1
			y = curcount // 2
			count += x * (x - 1) // 2 + y * (y - 1) // 2
		curcount = 1
		i += 1
print(count)


n = int(input())
s = [] * n
cnt = 0
a = {}
for i in range(n):
	t = input()
	s.append(t[0])
	k = t[0]
	if k in a:
		q = a[k]
		a[k] = q + 1
	else:
		f = {k: 1}
		a.update(f)
s.sort()
print('')
N = int(100)
dp = [0] * N
dp[1] = 0
dp[2] = 1
dp[3] = 3
for i in range(4, N, 1):
	dp[i] = i - 1 + dp[i - 1]
cnt = 0
for (key, value) in a.items():
	x = value // 2
	y = value - x
	cnt += dp[y] + dp[x]
print(cnt)


n = int(input())
a = [0] * 27
for i in range(n):
	s = input()
	a[ord(s[0]) - ord('a')] += 1

def fact(i, a):
	if i == 0:
		return a
	return fact(i - 1, a * i)
ans = 0
for i in a:
	if i > 1:
		k = i // 2
		ans += (i - k) * (i - k - 1) // 2 + k * (k - 1) // 2
print(ans)


from math import factorial

def comb2(n):
	if n >= 2:
		comb = factorial(n) / (2 * factorial(n - 2))
		return comb
	else:
		return 0
n = int(input())
freq = [0 for i in range(26)]
for i in range(n):
	palavra = input()
	ind = ord(palavra[0]) - ord('a')
	freq[ind] += 1
resp = 0
for elem in freq:
	if elem > 1:
		sala1 = elem // 2
		sala2 = elem - sala1
		resp += comb2(sala1)
		resp += comb2(sala2)
print(int(resp))


n = int(input())
d = dict()
for i in range(0, n):
	s = input()
	if d.get(s[0]) == None:
		d[s[0]] = 1
	else:
		d[s[0]] += 1
c = 0
for i in d.values():
	if i % 2 == 0:
		c += i // 2 * (i // 2 - 1)
	else:
		c += i // 2 * (i // 2)
print(c)


from collections import Counter

def pre_sum(arg):
	total = 0
	for x in range(1, arg):
		total += x
	return total
chat = Counter()
n = int(input(''))
for i in range(n):
	name = input('')
	chat[name[0]] += 1
min_pairs = 0
for y in chat:
	temp2 = int(chat[y] / 2)
	temp1 = chat[y] - temp2
	min_pairs += pre_sum(temp2)
	min_pairs += pre_sum(temp1)
print(min_pairs)


import math
num_de_estudantes = int(input())
aux1 = []
aux2 = []
combinacoes = []
for i in range(num_de_estudantes):
	nome = input()
	primeira_letra = nome[0]
	aux1.append(primeira_letra)
for letra in aux1:
	if letra not in aux2:
		aux2.append(letra)
		num = aux1.count(letra)
		if num >= 3:
			n1 = num // 2
			n2 = num - n1
			if n1 >= 2:
				combinacoes.append(math.factorial(n1) / (2 * math.factorial(n1 - 2)))
			combinacoes.append(math.factorial(n2) / (2 * math.factorial(n2 - 2)))
min_de_pares = int(sum(combinacoes))
print(min_de_pares)


from collections import Counter
out = 0
n = int(input())
a = []
for i in range(n):
	s = str(input())
	a.append(s[0])
c = Counter(a)
for d in c:
	if c[d] > 1:
		m = c[d]
		if m % 2 == 0:
			n = c[d] // 2
			out += n * (n - 1) // 2 + n * (n - 1) // 2
		else:
			n = c[d] // 2
			k = n + 1
			out += n * (n - 1) // 2 + k * (k - 1) // 2
print(out)


import math
d = {}
for _ in range(int(input())):
	i = input()[0]
	d[i] = d.get(i, 0) + 1
a = list(d.values())
s = 0
for i in a:
	k = i // 2
	s += k * (k - 1) // 2
	k = i - k
	s += k * (k - 1) // 2
print(s)


from math import factorial

def ncr(n, r):
	return factorial(n) // factorial(n - r) // factorial(r)
n = int(input())
li = []

def re(li, a):
	while a in li:
		li.remove(a)
	return li
coun = []
for j in range(n):
	li.append(input()[0])
while li != []:
	coun.append(li.count(li[0]))
	li = re(li, li[0])
coun = list(filter(lambda x: x > 2, coun))
ans = 0
for i in coun:
	if i == 3:
		ans += 1
	else:
		ans = ans + ncr(i // 2, 2) + ncr(i - i // 2, 2)
print(ans)


n = int(input())
names = []
for i in range(n):
	x = input()
	names.append(x[0])
al = {}
for i in names:
	al[i] = al.get(i, 0) + 1
a = 0
for i in list(al.keys()):
	if al[i] == 2:
		continue
	elif al[i] % 2 == 0:
		a += (al[i] - 1) // 2 * ((al[i] - 1) // 2 + 1)
	else:
		x = al[i] // 2
		a += x * (x + 1) // 2 + (x - 1) * x // 2
print(a)


import math
n_entradas = int(input())
turma1 = dict()
turma2 = dict()
combinacoes = 0
for i in range(n_entradas):
	entrada = input()
	if turma1.get(entrada[0]) == None:
		turma1[entrada[0]] = 1
	elif turma2.get(entrada[0]) == None:
		turma2[entrada[0]] = 1
	elif turma1.get(entrada[0]) <= turma2.get(entrada[0]):
		turma1[entrada[0]] += 1
	else:
		turma2[entrada[0]] += 1
for letra in turma1:
	if turma1.get(letra) != None and turma1.get(letra) > 1:
		calculo = math.factorial(turma1.get(letra)) / (2 * math.factorial(turma1.get(letra) - 2))
		combinacoes += calculo
for letra in turma2:
	if turma2.get(letra) != None and turma2.get(letra) > 1:
		calculo = math.factorial(turma2.get(letra)) / (2 * math.factorial(turma2.get(letra) - 2))
		combinacoes += calculo
print(int(combinacoes))


import collections, sys
n = int(sys.stdin.readline().rstrip())
ret = 0
d = collections.defaultdict(int)
for i in range(n):
	name = sys.stdin.readline().rstrip()
	letter = name[0]
	d[letter] += 1
for v in d.values():
	f = v // 2
	s = v - f
	ret += f * (f - 1) // 2
	ret += s * (s - 1) // 2
print(ret)


n = int(input())
one = [0 for _ in range(0, 123)]
two = [0 for _ in range(0, 123)]
for i in range(0, n):
	name = input()
	if one[ord(name[0])] >= two[ord(name[0])]:
		two[ord(name[0])] += 1
	else:
		one[ord(name[0])] += 1
sum = 0
for i in range(97, 123):
	if one[i] != 0:
		sum += one[i] * (one[i] - 1) / 2
for i in range(97, 123):
	if two[i] != 0:
		sum += two[i] * (two[i] - 1) / 2
print(int(sum))


a = 'abcdefghijklmnopqrstuvwxyz'
s = [[] for i in range(26)]
n = int(input())
for i in range(n):
	t = input()
	s[a.index(t[0])].append(t)
ans = 0

def fact(n):
	return 1 if n == 0 else n * fact(n - 1)

def c(n):
	if n < 2:
		return 0
	return fact(n) // (fact(n - 2) * fact(2))
for i in range(26):
	if len(s[i]) == 0:
		continue
	t = len(s[i])
	m = c(t)
	for k in range(1, t):
		if c(k) + c(t - k) < m:
			m = c(k) + c(t - k)
	ans += m
print(ans)


def C(n):
	return n * (n - 1) / 2
n = eval(input())
name = []
for i in range(n):
	name.append(input())
dic = {}
for i in name:
	if i[0] not in dic.keys():
		dic[i[0]] = 0
	dic[i[0]] += 1
sum = 0
for (i, j) in dic.items():
	if j <= 2:
		continue
	if j == 3:
		sum += 1
		continue
	if j % 2 == 0:
		sum += 2 * C(j / 2)
	else:
		sum += C(int(j / 2)) + C(int(j / 2 + 1))
print(int(sum))


import collections
n = int(input())
L = []
for i in range(n):
	L.append(input())
k = [x[0] for x in L]
ct = [count for (item, count) in collections.Counter(k).items() if count > 1]
x = 0
for nb in ct:
	f = nb // 2
	l = nb - f
	if f > 1:
		x += f * (f - 1) // 2
	if l > 1:
		x += l * (l - 1) // 2
print(x)


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
n = int(input(''))
a = []
cnt = 0
for ii in range(n):
	s = input('')
	a.append(s[0])
for i in range(97, 123):
	t = a.count(chr(i))
	if t > 4:
		if t % 2 == 0:
			cnt += 2 * nCr(t // 2, 2)
		else:
			cnt += nCr(t // 2 + 1, 2) + nCr(t // 2, 2)
	elif t == 2:
		cnt += 0
	else:
		cnt += t // 2
print(int(cnt))


n = int(input())
d = {}
for _ in range(n):
	c = input()[0]
	d[c] = d.get(c, 0) + 1
res = 0
for v in d.values():
	x = (v + 1) // 2
	res += x * (x - 1) // 2
	y = v - x
	res += y * (y - 1) // 2
print(res)


a = [0 for i in range(26)]
n = int(input())
for _ in range(n):
	p = input()
	a[ord(p[0]) - ord('a')] += 1
sum = 0
for i in range(26):
	if a[i] % 2 == 1:
		sum += a[i] // 2 * (a[i] // 2)
	else:
		sum += a[i] // 2 * (a[i] // 2 - 1)
print(sum)


n = int(input())
arr = [0] * 26
freq = [0] * 26
count = 0
for i in range(n):
	s = input()
	te = ord(s[0]) - ord('a')
	if arr[te] == 0:
		count += freq[te]
		freq[te] += 1
		arr[te] = 1
	else:
		count += freq[te] - 1
		arr[te] = 0
print(count)


import math

def ans(a):
	ar = a[:]
	ans = 0
	for i in ar:
		if i == 3:
			ans += 3
		elif i == 2:
			ans += 1
		elif i > 3:
			for j in range(1, i):
				ans += j
	return ans
a1 = [0] * 26
a2 = a1[:]
N = int(input())
for i in range(N):
	name = input()
	alph = ord(name[0]) - ord('a')
	if a1[alph] > a2[alph]:
		a2[alph] += 1
	else:
		a1[alph] += 1
ans = ans(a1) + ans(a2)
print(ans)


n = int(input())
di = dict()
count = 0
for i in range(n):
	string = input()
	char = string[0]
	if char in di:
		di[char] = di[char] + 1
	else:
		di[char] = 1
for j in di:
	if di[j] == 2:
		count = count + 0
	elif di[j] <= 4:
		count = count + di[j] // 2
	else:
		co = di[j] - di[j] // 2 - 1
		co = co * (co + 1) // 2
		count = count + co
		co = di[j] // 2 - 1
		co = co * (co + 1) // 2
		count = count + co
print(count)


from math import factorial as f

def nC2(n):
	if n > 1:
		return f(n) / (f(n - 2) * f(2))
	else:
		return 0
n = int(input())
alphas = {}
for i in range(n):
	temp = input()
	if temp[0] not in alphas.keys():
		alphas[temp[0]] = 1
	else:
		alphas[temp[0]] += 1
min = 0
for j in alphas.keys():
	n1 = int(alphas[j] / 2)
	n2 = alphas[j] - n1
	min += nC2(n1) + nC2(n2)
print(int(min))


n = int(input())
a = []
d = dict()
for x in range(n):
	s = input().rstrip()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
l = list(d.values())
count = 0
for i in l:
	if i % 2 == 1:
		c = i // 2
		count += c * (c - 1) // 2
		c = i // 2 + 1
		count += c * (c - 1) // 2
	if i % 2 == 0:
		c = i // 2
		count += c * (c - 1)
print(count)


IL = lambda : list(map(int, input().split()))

def f(x):
	return x * (x - 1) // 2
n = int(input())
N = sorted([input()[0] for i in range(n)])
(c1, c2) = (N[::2], N[1::2])
print(sum((f(c1.count(l)) for l in set(c1))) + sum((f(c2.count(l)) for l in set(c2))))


def nCr(n, r):
	import math
	f = math.factorial
	return f(n) // f(r) // f(n - r)
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
s = []
for _ in range(ii()):
	s.append(input()[0])
from collections import Counter
cc = Counter(s)
d = {}
for (i, j) in cc.items():
	if j > 1:
		d[i] = j
c = 0
for (i, j) in d.items():
	c1 = j // 2
	c2 = j - c1
	if c1 > 1:
		c += nCr(c1, 2)
	if c2 > 1:
		c += nCr(c2, 2)
print(c)


n = int(input())
freq = [0] * 26
for i in range(n):
	s = input()
	freq[ord(s[0]) - ord('a')] += 1
ans = 0
one = [0] * 26
two = [0] * 26
for i in range(26):
	one[i] = freq[i] // 2
	two[i] = freq[i] - one[i]
ans = 0
for i in range(26):
	ans += one[i] * (one[i] - 1) // 2
	ans += two[i] * (two[i] - 1) // 2
print(ans)


n = int(input())
dic = {}
for i in range(n):
	s = input()
	if s[0] in dic:
		dic[s[0]] += 1
	else:
		dic[s[0]] = 1
result = 0
for (k, v) in dic.items():
	if v % 2 == 0:
		a = v // 2
		a = a * (a - 1) // 2
		result += a * 2
	else:
		a = v // 2 + 1
		b = v // 2
		a = a * (a - 1) // 2
		b = b * (b - 1) // 2
		result += a + b
print(result)


import math
n = int(input())
l = []

def nc2(n):
	return math.factorial(n) / (math.factorial(n - 2) * 2)
for i in range(n):
	l.append(str(input())[0])
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
ans = 0
for (k, v) in d.items():
	if v < 3:
		ans += 0
	elif v == 3:
		ans += 1
	elif v % 2 == 0:
		ans += 2 * nc2(v // 2)
	else:
		ans += nc2(v // 2) + nc2(v // 2 + 1)
print(int(ans))


n = int(input())
a = []
count = [0] * 26
for i in range(n):
	count[int(ord(input()[0]) - ord('a'))] += 1
	ans = 0
for i in range(len(count)):
	n = count[i] // 2
	n2 = count[i] - n
	ans += (n * (n - 1) + n2 * (n2 - 1)) / 2
print(int(ans))


b = int(input())
people = [input()[0] for _ in range(b)]
list_1 = []
list_2 = []
for name in people:
	if list_1.count(name) > list_2.count(name):
		list_2.append(name)
	else:
		list_1.append(name)

def prog_func(n):
	return 0 if n == 1 else prog_func(n - 1) + n - 1
pairs = 0
for group in (list_1, list_2):
	for l in set(group):
		pairs += prog_func(group.count(l))
print(pairs)


t = int(input())
arr = [0 for i in range(26)]
for test in range(t):
	s = input()
	arr[ord(s[0]) - 97] += 1
ans = 0
for i in range(26):
	temp1 = arr[i] // 2
	temp2 = arr[i] - temp1
	ans += temp1 * (temp1 - 1) // 2
	ans += temp2 * (temp2 - 1) // 2
print(ans)


from collections import Counter
n = int(input())
c = Counter((input()[0] for _ in range(n)))
ans = 0
for v in c.values():
	a = v // 2
	b = v - a
	ans += a * (a - 1) // 2
	ans += b * (b - 1) // 2
print(ans)


dl = [0 for i in range(ord('z') - ord('a') + 1)]
a = ord('a')
n = int(input())
for i in range(n):
	s = input()
	dl[ord(s[0]) % a] += 1
res = 0
for i in range(ord('z') - ord('a') + 1):
	t = dl[i]
	if t % 2 == 0:
		res += t // 2 * (t // 2 - 1)
	else:
		res += t // 2 * (t // 2 - 1) // 2 + t // 2 * (t // 2 + 1) // 2
print(res)


from collections import defaultdict

def solve():
	freq = defaultdict(int)
	for _ in range(int(input())):
		s = input()
		freq[s[0]] += 1
	ans = 0
	for x in freq.values():
		if x > 1:
			a = x // 2
			b = x - a
			ans += a * (a - 1) // 2 + b * (b - 1) // 2
	print(ans)
solve()


def calc(x):
	return x * (x - 1) // 2
n = int(input())
l = [0 for i in range(26)]
for i in range(n):
	s = input()
	l[ord(s[0]) - ord('a')] += 1
ans = 0
for i in range(26):
	t1 = l[i] // 2
	t2 = l[i] - t1
	ans += calc(t1)
	ans += calc(t2)
print(ans)


n = int(input())
f = [0] * 26
while n:
	n -= 1
	tmp = input()
	f[ord(tmp[0]) - ord('a')] += 1
sum = 0
for i in f:
	a = i // 2
	b = i - a
	sum += a * (a - 1) // 2 + b * (b - 1) // 2
print(sum)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		d = {}
		for x in range(n):
			l = input()
			if d.get(l[0], -1) != -1:
				d[l[0]] += 1
			else:
				d[l[0]] = 1
		ans = 0
		for x in d:
			t1 = math.ceil(d[x] / 2)
			t2 = d[x] - t1
			ans += t1 * (t1 - 1) // 2
			ans += t2 * (t2 - 1) // 2
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


n = int(input())
l = []
c = 0
for i in range(n):
	name = input()
	l.append(name)
l.sort()
l1 = []
l2 = []
if len(l) % 2 == 0:
	for i in range(0, len(l), 2):
		l1.append(l[i])
		l2.append(l[i + 1])
elif len(l) == 1:
	l1.append(l[i])
else:
	for i in range(0, len(l) - 1, 2):
		l1.append(l[i])
		l2.append(l[i + 1])
	l1.append(l[i + 2])
for i in range(len(l1)):
	for j in range(i + 1, len(l1)):
		if l1[i][0] == l1[j][0]:
			c = c + 1
for i in range(len(l2)):
	for j in range(i + 1, len(l2)):
		if l2[i][0] == l2[j][0]:
			c = c + 1
print(c)


N = int(input())

def comb(a):
	return a * (a - 1) / 2
l1 = {}
for i in range(N):
	temp = str(input())
	if temp[0] in l1.keys():
		l1[temp[0]] += 1
	else:
		l1[temp[0]] = 1
sum = 0
for key in l1.keys():
	a = l1[key]
	b = int(a / 2)
	c = a - b
	sum += comb(b) + comb(c)
print(int(sum))


n = int(input())
s = {}
for i in range(n):
	q = input()
	if q[0] in list(s.keys()):
		s[q[0]] += 1
	else:
		s[q[0]] = 1
u = []
ans = 0
for i in list(s.keys()):
	k = s[i]
	u.append(k)
	a = k // 2
	b = k - a
	ans += (a - 1) * a // 2 + (b - 1) * b // 2
print(ans)


n = int(input())
import string
d = dict(zip(string.ascii_lowercase, [*[0] * 26]))
for i in range(n):
	s = input()
	d[s[0]] += 1
c = 0
for i in d.values():
	if i:
		if i % 2 == 0:
			c += i * (i - 2) / 4
		else:
			c += (i // 2) ** 2
print(int(c))


def chatty(s, c):
	pairs = -1
	for i in c:
		if s[0] == i[0]:
			pairs += 1
	return pairs
n = int(input())
a = []
x = 0
(class1, class2) = ([], [])
for i in range(n):
	a.append(input())
for i in a:
	if chatty(i, class1) <= chatty(i, class2):
		class1.append(i)
		x += chatty(i, class1)
	else:
		class2.append(i)
		x += chatty(i, class2)
print(x)


import math as m
import collections as clt
number_of_students = 0
name = []
first_letter = []
result = 0

def Input(number_of_students, name):
	number_of_students = int(input())
	for index in range(number_of_students):
		name.append(input())
	return (number_of_students, name)

def Permutation2(n):
	return n * (n - 1) // 2

def Output(number_of_students, name, first_letter):
	result = 0
	for x in first_letter.values():
		result += Permutation2(x // 2) + Permutation2(x - x // 2)
	print(result)

def Processing(number_of_students, name, first_letter):
	for x in name:
		first_letter.append(x[0])
	first_letter = clt.Counter(first_letter)
	return first_letter
(number_of_students, name) = Input(number_of_students, name)
first_letter = Processing(number_of_students, name, first_letter)
Output(number_of_students, name, first_letter)


def nc2(n):
	if n < 2:
		return 0
	else:
		return int(n * (n - 1) / 2)
n = int(input())
ar = [0] * 26
for w in range(n):
	s = list(input())
	ar[ord(s[0]) - 97] += 1
c = 0
for i in range(26):
	a = ar[i] // 2
	b = ar[i] - a
	c += nc2(a) + nc2(b)
print(c)


a = []
b = []
p = 0
for i in range(int(input())):
	x = input()[0]
	if a.count(x) <= b.count(x):
		a.append(x)
	else:
		b.append(x)
for i in range(len(a) - 1):
	for t in range(i + 1, len(a)):
		if a[i] == a[t]:
			p += 1
for i in range(len(b) - 1):
	for t in range(i + 1, len(b)):
		if b[i] == b[t]:
			p += 1
print(p)


from collections import Counter
from math import ceil, factorial

def solve(n, a):
	c = Counter(a)
	s = 0
	for k in c.values():
		v = k // 2
		if k % 2 == 0:
			s += v * (v - 1)
		else:
			s += (v + 1) * v // 2
			s += v * (v - 1) // 2
	return s

def main():
	n = int(input())
	a = [input()[0] for _ in range(n)]
	print(solve(n, a))
main()


import math
n = int(input())
list1 = []
for i in range(n):
	list1.append(input())
list1.sort()
list2 = [w[0] for w in list1[1::2]]
list3 = [w[0] for w in list1[0::2]]
freq1 = []
freq2 = []
for w in set(list2):
	freq1.append(list2.count(w))
for w in set(list3):
	freq2.append(list3.count(w))
ans = 0
for ele in freq1 + freq2:
	if ele > 1:
		ans += math.factorial(ele) / math.factorial(ele - 2) / math.factorial(2)
print(int(ans))


import math

def ncr(n, r):
	if n - r < 0:
		return math.factorial(n) // math.factorial(r)
	else:
		return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
n = int(input())
s = []
for i in range(n):
	l = input()
	s.append(l[0])
d = {}
for i in range(len(s)):
	d[s[i]] = 0
for i in range(len(s)):
	d[s[i]] += 1
p = 0
for key in d:
	p += ncr(d[key] // 2, 2) + ncr(d[key] - d[key] // 2, 2)
print(p)


from collections import Counter
n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x[0])
d = Counter(a)
d = dict(d)
di = d.values()
di = list(di)
s = 0
for i in di:
	if i == 1 and i == 2:
		continue
	else:
		u = i // 2
		v = i - u
		s += u * (u - 1) // 2 + v * (v - 1) // 2
print(s)


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(x)
l.sort()
k = []
c = 1
f = 0
g = 0
for i in range(n - 1):
	if l[i][0] == l[i + 1][0]:
		c += 1
		g = 0
		if i == n - 2:
			f = 1
	else:
		k.append(c)
		g = 1
		c = 1
if f == 0:
	k.append(1)
if g == 0:
	k.append(c)
ans = 0
for j in range(len(k)):
	if k[j] > 1:
		x = int(k[j] / 2)
		y = k[j] - x
		ans += int((x * (x - 1) + y * (y - 1)) / 2)
print(ans)


n = int(input())
s1 = []
s2 = []
for i in range(n):
	s = input()[0]
	if s not in s1 and s not in s2:
		s1.append(s)
	elif s in s1 and s not in s2:
		s2.append(s)
	elif s in s2 and s not in s1:
		s2.append(s)
	elif s1.count(s) >= s2.count(s):
		s2.append(s)
	else:
		s1.append(s)
count = 0
for i in set(s1):
	c = s1.count(i)
	count += c * (c - 1) // 2
for j in set(s2):
	c2 = s2.count(j)
	count += c2 * (c2 - 1) // 2
print(count)


n = int(input())
a = []
ans = 0
for i in range(30):
	a.append(0)
for i in range(n):
	s = input()
	a[ord(s[0]) - ord('a')] += 1
for i in range(29):
	if a[i] > 0:
		ans += a[i] // 2 * (a[i] // 2 - 1) // 2
		a[i] += 1
		ans += a[i] // 2 * (a[i] // 2 - 1) // 2
print(ans)


from collections import Counter

def pair(n):
	res = 0
	for i in range(n):
		res += i
	return res
n = int(input().strip())
name_counter = Counter()
for _ in range(n):
	name_counter[input().strip()[0]] += 1
res = 0
for count in name_counter.values():
	res += pair(count // 2) + pair(count // 2 + count % 2)
print(res)


n = int(input())
d = {}
for i in range(n):
	s = input()[0]
	if d.get(s) == None:
		d[s] = 1
	else:
		d[s] += 1
res = 0
for i in d.values():
	if i < 2:
		continue
	a = i // 2
	b = i - a
	res += a * (a - 1) // 2
	res += b * (b - 1) // 2
print(res)


import math

def combination2(a):
	return math.factorial(a) / (math.factorial(2) * math.factorial(a - 2))
n = int(input())
first_letter_table = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
for i in range(n):
	masukan = input()
	first_letter_table[masukan[0]] += 1
x = 0
for alphabet in first_letter_table:
	num = first_letter_table[alphabet]
	if num == 0 or num == 1 or num == 2:
		pass
	elif num == 3:
		x += 1
	elif num > 3:
		num1 = num // 2
		num2 = num - num1
		x += combination2(num1) + combination2(num2)
print(int(x))


from collections import Counter
n = int(input())
l = [input()[0] for _ in range(n)]
cc = Counter(l)
x = 0
for i in cc.values():
	if i > 2:
		if i % 2 == 0:
			i = i // 2
			x += i * (i - 1)
		else:
			i = i // 2
			x += i * (i - 1) // 2
			x += i * (i + 1) // 2
print(x)


def C(n):
	if n < 2:
		return 0
	return n * (n - 1) // 2
m = {}
for _ in range(int(input())):
	s = input()
	if s[0] in m:
		m[s[0]] += 1
	else:
		m[s[0]] = 1
res = 0
for j in m:
	res += C(m[j] // 2) + C(m[j] // 2 + (m[j] % 2 > 0))
print(res)


def f(n):
	if n == 0 or n == 1 or n == 2:
		return 0
	elif n == 3:
		return 1
	elif n == 4:
		return 2
	else:
		k = round(n / 2)
		m = n - k
		return int(k * (k - 1) / 2 + m * (m - 1) / 2)
n = int(input())
min_talk = 0
names = {letter: 0 for letter in 'qwertyuiopasdfghjklzxcvbnm'}
for i in range(n):
	name = input()
	names[name[0]] += 1
for k in names:
	min_talk += f(names[k])
print(min_talk)


n = int(input())
x = []
counter = 0
m = 0
for i in range(n):
	x.append(input()[0])
for i in set(x):
	tmp = x.count(i) // 2
	tmp2 = x.count(i) - tmp
	m += tmp * (tmp - 1) // 2
	m += tmp2 * (tmp2 - 1) // 2
print(m)


from collections import Counter
from math import factorial
n = int(input())
nm = [input()[0] for i in range(n)]
nm.sort()
a = []
b = []
for i in range(n):
	if i % 2 == 0:
		a.append(nm[i])
	else:
		b.append(nm[i])
ca = Counter(a)
cb = Counter(b)
s = 0
for i in ca:
	if ca[i] > 1:
		s += factorial(ca[i]) / 2 / factorial(ca[i] - 2)
for i in cb:
	if cb[i] > 1:
		s += factorial(cb[i]) / 2 / factorial(cb[i] - 2)
print(int(s))


n = int(input())
dic = {}
for i in range(n):
	tem = str(input())
	cache = tem[0]
	if dic.get(cache, 0) == 0:
		dic.update({cache: 1})
	else:
		dic[cache] += 1
s = 0
for i in dic.keys():
	if dic[i] <= 2:
		continue
	cache = dic[i]
	tem = int(cache / 2)
	s += tem * (tem - 1) / 2 + (cache - tem) * (cache - tem - 1) / 2
print(int(s))


(n, d, count) = (int(input()), {}, 0)
for _ in range(n):
	ch = input()[0]
	if ch in d:
		d[ch] += 1
	else:
		d[ch] = 1
for a in d.values():
	b = a // 2
	count += (b * (b - 1) + (a - b) * (a - b - 1)) // 2
print(count)


def main():
	n = int(input())
	first = {}
	second = {}
	for i in range(n):
		s = input()
		if s[0] not in first:
			first[s[0]] = 1
		elif s[0] not in second:
			second[s[0]] = 1
		elif first[s[0]] > second[s[0]]:
			second[s[0]] += 1
		else:
			first[s[0]] += 1
	ans = 0
	for i in first:
		ans += first[i] * (first[i] - 1) // 2
	for i in second:
		ans += second[i] * (second[i] - 1) // 2
	print(ans)
main()


a = [0] * 26
for i in range(int(input())):
	a[ord(input()[0]) - 97] += 1
ans = 0
for v in a:
	if v == 3:
		ans += 1
	elif v > 3:
		ans += v // 2 * (v // 2 - 1) // 2
		w = v - v // 2
		ans += w * (w - 1) // 2
print(ans)


from collections import defaultdict
n = int(input().strip())
names = []
for i in range(n):
	names.append(input().strip())
names.sort()
class1 = defaultdict(int)
class2 = defaultdict(int)
first_letter_index = defaultdict(int)
for i in range(n):
	if names[i][0] not in first_letter_index:
		class1[names[i][0]] += 1
		first_letter_index[names[i][0]] = 2
	elif first_letter_index[names[i][0]] == 1:
		class1[names[i][0]] += 1
		first_letter_index[names[i][0]] = 2
	else:
		class2[names[i][0]] += 1
		first_letter_index[names[i][0]] = 1
ans = 0
for i in class1:
	ans += class1[i] * (class1[i] - 1) // 2
for i in class2:
	ans += class2[i] * (class2[i] - 1) // 2
print(ans)


n = int(input())
l = []
hasVisited = {}
for i in range(n):
	l.append(input()[0])
	if l[i] not in hasVisited:
		hasVisited[l[i]] = 1
	else:
		hasVisited[l[i]] += 1
sum = 0
for i in hasVisited:
	a1 = hasVisited[i] // 2
	a2 = hasVisited[i] - a1
	sum += a1 * (a1 - 1) // 2 + a2 * (a2 - 1) // 2
print(sum)


from collections import defaultdict

def C2(n):
	return n * (n - 1) / 2
m = defaultdict(int)
n = int(input())
for x in range(n):
	s = input()
	m[s[0]] += 1
ans = 0
for c in m:
	amt = m[c]
	mn = 1000000000.0
	for i in range(amt // 2 + 1):
		mn = min(mn, C2(i) + C2(amt - i))
	ans += mn
print(int(ans))


n = int(input())
s = {}
for i in range(n):
	ss = input()
	try:
		s[ss[0]] += 1
	except:
		s[ss[0]] = 1
k = [0, 0]
for i in s:
	a = s[i] // 2
	b = s[i] - a
	k[0] += a * (a - 1) // 2
	k[1] += b * (b - 1) // 2
print(sum(k))


n = int(input())
names = []
for i in range(n):
	names.append(input()[0])
names = sorted(names)

def combination(n):
	return n * (n - 1) // 2 if n > 0 else 0

def add_sum(n):
	sum = 0
	if counter % 2:
		sum += combination(counter // 2)
		sum += combination(counter // 2 + 1)
	else:
		sum += 2 * combination(counter // 2)
	return sum
sum = 0
counter = 0
prev_name = ''
for name in names:
	if prev_name != name:
		sum += add_sum(counter)
		counter = 1
		prev_name = name
		continue
	else:
		counter += 1
sum += add_sum(counter)
print(sum)


from math import factorial as f

def c(x):
	return f(x) // (2 * f(x - 2))
n = int(input())
s = []
for i in range(n):
	s.append(input()[0])
s.sort()
ans = 0
k = 1
for i in range(1, n):
	if s[i] == s[i - 1]:
		k += 1
	else:
		if k > 2:
			a1 = k // 2
			a2 = k // 2 + int(bool(k % 2))
			if a1 > 1:
				ans += c(a1)
			if a2 > 1:
				ans += c(a2)
		k = 1
if k > 2:
	a1 = k // 2
	a2 = k // 2 + int(bool(k % 2))
	if a1 > 1:
		ans += c(a1)
	if a2 > 1:
		ans += c(a2)
print(ans)


n = int(input())
a = [0] * 27
for i in range(n):
	s = input()
	a[ord(s[0]) - ord('a')] += 1
ans = 0
for i in range(26):
	t = a[i] // 2
	k = a[i] - t
	ans += t * (t - 1) // 2
	ans += k * (k - 1) // 2
print(ans)


n = int(input())
counter = 0
dic = {}
for i in range(n):
	a = list(input())
	if a[0] not in dic:
		dic[a[0]] = 1
	else:
		dic[a[0]] += 1
for item in dic:
	y = dic[item]
	x = dic[item] // 2
	counter += x * (x - 1) // 2 + (y - x) * (y - x - 1) // 2
print(counter)


from sys import stdin, stdout
names = []
names_l = []
letter_ind = {}
n = int(stdin.readline().rstrip())
for i in range(n):
	name = stdin.readline().rstrip()
	names.append(name)
	names_l.append(name[0])
	letter_ind[i] = name[0]
test = {k: v for (k, v) in sorted(letter_ind.items(), key=lambda item: item[1])}
dict_letter = {}
for item in test.values():
	if item in dict_letter.keys():
		dict_letter[item].append(item)
	else:
		dict_letter[item] = [item]
running_sum = 0
for item in dict_letter.values():
	if len(item) - len(item) // 2 > 1:
		x = len(item) - len(item) // 2
		y = len(item) // 2
		running_sum += x * (x - 1) / 2
		running_sum += y * (y - 1) / 2
stdout.write(str(int(running_sum)))


ss1 = {}
ss2 = {}
for _ in range(int(input())):
	s = input()
	if s[0] in ss1 and s[0] in ss2:
		if ss1[s[0]] < ss2[s[0]]:
			ss1[s[0]] += 1
		else:
			ss2[s[0]] += 1
	elif s[0] in ss2:
		ss1[s[0]] = 1
	else:
		ss2[s[0]] = 1
ans = 0
for i in ss1:
	x = ss1[i]
	ans += x * (x - 1) // 2
for i in ss2:
	x = ss2[i]
	ans += x * (x - 1) // 2
print(ans)


d = dict()
n = int(input())
for i in range(n):
	s = input()
	t = s[0]
	if not t in d:
		d[t] = 1
	else:
		d[t] += 1
ans = 0
mf = 0
for i in d:
	ans = d[i]
	t = (ans + 1) // 2
	t2 = ans // 2
	mf += t * (t - 1) // 2 + t2 * (t2 - 1) // 2
print(mf)


from math import factorial

def comb(a, b):
	return factorial(a) // factorial(b) // factorial(a - b)
N = int(input())
students = [input() for _ in range(N)]
a = [0] * 26
for st in students:
	idx = ord(st[0]) - ord('a')
	a[idx] += 1
result = 0
for n in a:
	if n >= 3:
		p = n // 2
		if p >= 2:
			result += comb(p, 2)
		if n - p >= 2:
			result += comb(n - p, 2)
print(result)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
n = nn()
names = []
for i in range(n):
	names.append(input())
firsts = dd(int)
for n in names:
	firsts[n[0]] += 1
m = 0
chatty = 0
for let in firsts:
	num = firsts[let]
	c1 = (num + 1) // 2
	c2 = num // 2
	chatty = chatty + c1 * (c1 - 1) // 2 + c2 * (c2 - 1) // 2
print(chatty)


from collections import defaultdict as dd
import math
n = int(input())
v = dd(int)
for _ in range(n):
	s = str(input())
	v[s[0]] += 1
h = list(v.keys())
c = 0
for i in h:
	a = math.ceil(v[i] / 2)
	b = int(v[i] / 2)
	c += int(a * (a - 1) / 2)
	c += int(b * (b - 1) / 2)
print(c)


n = int(input())
a = [0 for i in range(26)]
for i in range(n):
	q = input()
	a[ord(q[0]) - 97] += 1
count = 0
for i in range(26):
	x = a[i] // 2
	y = a[i] - x
	count = count + x * (x - 1) // 2 + y * (y - 1) // 2
print(count)


d = [0] * 26
for i in range(int(input())):
	s = input()
	d[ord(s[0]) - 97] += 1
ans = 0
for i in d:
	n = i // 2
	if i % 2 == 0:
		ans += n * (n - 1)
	else:
		ans += n * (n - 1) // 2
		ans += n * (n + 1) // 2
print(ans)


import math

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
a = []
c = [0] * 26
for _ in range(int(input())):
	b = input()
	a.append(b[0])
for i in a:
	c[ord(i) - 97] += 1
total = 0
for j in c:
	if j == 3:
		total += 1
	if j == 4:
		total += 2
	if j > 4:
		first = j // 2
		second = j - first
		total += nCr(first, 2) + nCr(second, 2)
print(total)


from collections import defaultdict
di = defaultdict(lambda : 0)
n = int(input())
for i in range(n):
	a = input()
	if di[a[0]] == 0:
		di[a[0]] = 1
	else:
		di[a[0]] += 1
s = 0
for i in range(26):
	if di[chr(97 + i)] > 2:
		c = di[chr(97 + i)] // 2
		s1 = c * (c - 1) / 2
		c = di[chr(97 + i)] - c
		s2 = c * (c - 1) / 2
		s = s1 + s2 + s
print(int(s))


def nCr(n, r):
	if r > n / 2:
		a = r + 1
		return round(fact(n, a) / fact(n - r))
	else:
		a = n - r + 1
		return round(fact(n, a) / fact(r))

def fact(n, r=2):
	res = round(1)
	for i in range(r, n + 1):
		res = res * i
	return round(res)
n = int(input())
counter = []
for i in range(26):
	counter.append(0)
var = ''
a_val = ord('a')
for i in range(n):
	var = input()
	counter[ord(var[0]) - a_val] += 1
result = 0
for i in range(26):
	middle = counter[i] // 2
	if counter[i] >= 3:
		if counter[i] - middle >= 2:
			result += nCr(counter[i] - middle, 2)
		if middle >= 2:
			result += nCr(middle, 2)
print(result)


n = int(input())
dc = [0 for _ in range(26)]
for i in range(n):
	s = input().strip()
	dc[ord(s[0]) - ord('a')] += 1
ans = 0
for i in dc:
	x = i // 2
	if i % 2 == 0:
		y = x
	else:
		y = x + 1
	ans += int(x * (x - 1) / 2)
	ans += int(y * (y - 1) / 2)
print(ans)


N = int(input())
name = [''] * N
freq = {}
for i in range(26):
	freq[chr(97 + i)] = 0
for i in range(N):
	s = input()
	name[i] = s
	freq[s[0]] += 1
ans = 0
for i in range(26):
	num = freq[chr(97 + i)]
	if num >= 2:
		A = num // 2
		B = num - A
		ans += A * (A - 1) // 2
		ans += B * (B - 1) // 2
print(ans)


a = dict()
for i in range(26):
	a[chr(97 + i)] = 0
for _ in range(int(input())):
	l = list(input())
	a[l[0]] += 1
su = 0
for i in a:
	if a[i] > 1:
		b = a[i] // 2
		su += (b * (b - 1) + (a[i] - b) * (a[i] - b - 1)) / 2
print(int(su))


import math
n = int(input())
count = [0] * 26
for i in range(0, n):
	name = input()[0]
	if name == 'a':
		count[0] += 0.5
	elif name == 'b':
		count[1] += 0.5
	elif name == 'c':
		count[2] += 0.5
	elif name == 'd':
		count[3] += 0.5
	elif name == 'e':
		count[4] += 0.5
	elif name == 'f':
		count[5] += 0.5
	elif name == 'g':
		count[6] += 0.5
	elif name == 'h':
		count[7] += 0.5
	elif name == 'i':
		count[8] += 0.5
	elif name == 'j':
		count[9] += 0.5
	elif name == 'k':
		count[10] += 0.5
	elif name == 'l':
		count[11] += 0.5
	elif name == 'm':
		count[12] += 0.5
	elif name == 'n':
		count[13] += 0.5
	elif name == 'o':
		count[14] += 0.5
	elif name == 'p':
		count[15] += 0.5
	elif name == 'q':
		count[16] += 0.5
	elif name == 'r':
		count[17] += 0.5
	elif name == 's':
		count[18] += 0.5
	elif name == 't':
		count[19] += 0.5
	elif name == 'u':
		count[20] += 0.5
	elif name == 'v':
		count[21] += 0.5
	elif name == 'w':
		count[22] += 0.5
	elif name == 'x':
		count[23] += 0.5
	elif name == 'y':
		count[24] += 0.5
	elif name == 'z':
		count[25] += 0.5
count = [j for j in count if j > 1]
t = 0
r = 2
for i in count:
	if int(i) == 1:
		t += 1
	elif i == int(i):
		k = i - r
		c = 2 * math.factorial(i) / (math.factorial(k) * math.factorial(r))
		t += c
	else:
		i = int(i)
		k = i - r
		c = math.factorial(i + 1) / (math.factorial(k + 1) * math.factorial(r)) + math.factorial(i) / (math.factorial(k) * math.factorial(r))
		t += c
print(int(t))


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from itertools import permutations, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	n = fi()
	d = {}
	for i in range(n):
		s = si()
		inc(d, s[0])
	c = 0
	for i in d:
		p = d[i] // 2
		q = (d[i] + 1) // 2
		c += (p * p - p) // 2 + (q * q - q) // 2
	print(c)


n = int(input())
l = [input()[0] for _ in range(n)]
class_a = [0 for _ in range(26)]
class_b = [0 for _ in range(26)]
x = 0
for i in l:
	order = ord(i) - 97
	if class_a[order] < class_b[order]:
		class_a[order] += 1
		x = x + class_a[order] - 1
	else:
		class_b[order] += 1
		x = x + class_b[order] - 1
print(x)


n = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = {}
for char in alphabet:
	count[char] = 0
for i in range(n):
	name = input()
	count[name[0]] += 1
sumi = 0
for guy in count:
	a = count[guy]
	b = a // 2
	c = a - b
	sumi += b * (b - 1) // 2 + c * (c - 1) // 2
print(sumi)


from collections import defaultdict
import math
n = int(input())
d = defaultdict(lambda : 0)
for nn in range(n):
	nm = input()
	f = nm[0]
	d[f] += 1
cnt = 0
for k in d.keys():
	if d[k] > 2:
		c1 = math.floor(d[k] / 2)
		c2 = math.ceil(d[k] / 2)
		if c1 > 1:
			cnt += c1 * (c1 - 1) / 2
		if c2 > 1:
			cnt += c2 * (c2 - 1) / 2
print(int(cnt))


n = int(input())
a = [input() for i in range(n)]
(c, d) = (0, {})
for i in range(n):
	if a[i][0] not in d:
		d[a[i][0]] = 1
	else:
		d[a[i][0]] += 1
for i in d.keys():
	if d[i] > 2:
		if d[i] & 1:
			p = (d[i] + 1) // 2
			q = (d[i] - 1) // 2
			c += p * (p - 1) // 2
			c += q * (q - 1) // 2
		else:
			c += 2 * (d[i] // 2 * (d[i] // 2 - 1) // 2)
print(c)


from math import ceil
n = int(input())
d = {}
sum = 0
for i in range(n):
	t = input()
	if t[0] in d:
		d[t[0]] += 1
	else:
		d[t[0]] = 1
for i in d.values():
	a = ceil(i / 2)
	b = i // 2
	sum += (a * (a - 1) + b * (b - 1)) // 2
print(sum)


from collections import defaultdict
from math import ceil
(b, ans) = (defaultdict(int), 0)
for i in range(int(input())):
	b[input()[0]] += 1
for i in b.values():
	ans += i // 2 * (i // 2 - 1) // 2 + ceil(i / 2) * (ceil(i / 2) - 1) // 2
print(ans)


n = int(input())
abc = 'qwertyuiopasdfghjklzxcvbnm'
l = []
total = 0
for i in range(len(abc)):
	l.append(0)
for i in range(n):
	s = input()
	for i in range(len(abc)):
		if s[0] == abc[i]:
			l[i] = l[i] + 1
for i in range(len(l)):
	if l[i] != 0:
		total += l[i] // 2 * (l[i] // 2 - 1) / 2
		total += (l[i] - l[i] // 2) * (l[i] - l[i] // 2 - 1) / 2
print(int(total))


import math
n = int(input())
l = []
for i in range(n):
	s = str(input())
	l.append(s[0].lower())
c1 = {}
c2 = {}
for i in range(97, 123):
	c1[chr(i)] = 0
	c2[chr(i)] = 0
count = 0
for i in l:
	if c1[i] == 0:
		c1[i] += 1
	elif c2[i] == 0:
		c2[i] += 1
	elif c2[i] < c1[i]:
		c2[i] += 1
	else:
		c1[i] += 1
for i in c1:
	if c1[i] >= 2:
		x = math.factorial(c1[i]) / (math.factorial(c1[i] - 2) * 2)
		count += x
for i in c2:
	if c2[i] >= 2:
		y = math.factorial(c2[i]) / (math.factorial(c2[i] - 2) * 2)
		count += y
print(int(count))


import sys
from collections import defaultdict
DEBUG = False
if DEBUG:
	inf = open('input.txt')
else:
	inf = sys.stdin
N = int(inf.readline())
fchars = defaultdict(int)
for i in range(N):
	name = inf.readline()
	fchar = name[0]
	fchars[fchar] += 1

def calc_x(same_cnt):
	return same_cnt * (same_cnt - 1) // 2
tot = 0
for (name, count) in fchars.items():
	if count >= 3:
		a = count // 2
		b = count - a
		tot += calc_x(a) + calc_x(b)
print(tot)


k = [input()[0] for i in ' ' * int(input())]
e = list(set(k))
s = 0
import math
for i in range(len(e)):
	z = k.count(e[i]) // 2
	x = math.ceil(k.count(e[i]) / 2)
	s = s + z * (z - 1) // 2 + x * (x - 1) // 2
print(s)


sos = dict()
for i in range(int(input())):
	s = input()
	if s[0] not in sos:
		sos[s[0]] = 0
	sos[s[0]] += 1
cnt = 0
for i in sos:
	a = sos[i]
	cnt += a // 2 * (a // 2 - 1) // 2
	a += 1
	cnt += a // 2 * (a // 2 - 1) // 2
print(cnt)


from collections import Counter
n = []
for i in range(int(input())):
	a = input()
	n.append(a[0])
cnt = 0
p = Counter(n)
for i in p:
	if p[i] > 2:
		f = p[i] // 2
		s = p[i] - f
		cnt += f * (f - 1) / 2 + s * (s - 1) / 2
print(int(cnt))


def f(n):
	if n <= 1:
		return 1
	else:
		return n * f(n - 1)
n = int(input())
d = dict()
for i in range(n):
	name = input()[0]
	if name in d:
		d[name] += 1
	else:
		d[name] = 1
x = 0
for v in d.values():
	if v > 1:
		t = v // 2
		x += f(t) // (2 * f(t - 2))
		t = v - v // 2
		x += f(t) // (2 * f(t - 2))
print(x)


n = int(input())
f = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}
for i in range(n):
	r = input()
	f[r[0]] += 1
x = 0
for i in f:
	if f[i] == 0:
		continue
	elif f[i] == 1:
		continue
	elif f[i] == 2:
		continue
	elif f[i] == 3:
		x += 1
	elif f[i] % 2 == 0:
		x += f[i] // 2 * (f[i] // 2 - 1)
	else:
		x += f[i] // 2 * (f[i] // 2 - 1) // 2 + (f[i] + 1) // 2 * ((f[i] + 1) // 2 - 1) // 2
print(x)


n = int(input())
s = []
for i in range(26):
	s.append(0)
for i in range(n):
	s[ord(input()[0]) - ord('a')] += 1
c = 0
for i in range(26):
	a = s[i] // 2
	b = s[i] - a
	c += a * (a - 1) / 2 + b * (b - 1) / 2
print(int(c))


n = int(input())
l = [0] * 26
for _ in range(n):
	s = input()
	l[ord(s[0]) - 97] += 1
ans = 0
for i in range(26):
	x = l[i] // 2
	y = l[i] - x
	ans += x * (x - 1) // 2
	ans += y * (y - 1) // 2
print(ans)


def xc2(num):
	return num * (num - 1) // 2
n = int(input())
cnt = {}
for i in range(n):
	x = input()[0]
	try:
		cnt[x] += 1
	except KeyError:
		cnt[x] = 1
ans = 0
for (key, val) in cnt.items():
	x = val // 2
	y = val - x
	ans += xc2(x) + xc2(y)
print(ans)


n = int(input())
lis = [input()[0] for i in range(n)]
s = set(lis)
r = 0
for i in s:
	x = lis.count(i)
	(a, b) = (x // 2, x - x // 2)
	r += a * a + b * b - a - b
print(r // 2)


n = int(input())
l = [input()[0] for _ in range(n)]

def nC2(n):
	if n < 2:
		return 0
	return n * (n - 1) // 2

def f(v):
	if v % 2 == 0:
		return 2 * nC2(v // 2)
	else:
		return nC2(v // 2) + nC2(v // 2 + 1)
from collections import Counter
print(sum((f(v) for (k, v) in Counter(l).most_common())))


from collections import defaultdict
d = [0] * 1000
for el in range(1, 1000):
	val = el * (el - 1) // 2
	for p in range(el):
		rest = el - p
		score = p * (p - 1) // 2 + rest * (rest - 1) // 2
		val = min(val, score)
	d[el] = val
n = int(input())
names = defaultdict(lambda : 0)
for _ in range(n):
	s = input().strip().lower()
	names[s[0]] += 1
answer = sum([d[v] for v in names.values()])
print(answer)


from collections import Counter as C
n = int(input())
l = []
for i in range(n):
	k = input()
	l.append(k[0])
d = C(l)
f = 0
for i in d:
	if d[i] > 2:
		if d[i] == 3:
			f += 1
		elif d[i] % 2 == 0:
			a = d[i] // 2
			f += a * (a - 1)
		else:
			a = d[i] // 2
			a1 = d[i] // 2 + 1
			f += a * (a - 1) // 2 + a1 * (a1 - 1) // 2
print(f)


b = lambda x: (x * x - x) // 2
c = lambda x: b(x // 2) + b(0 - -x // 2)
a = [0] * 26
for _ in [0] * int(input()):
	a[ord(input()[0]) - 97] += 1
print(sum(map(c, a)))


def givepairs(n):
	return n * (n - 1) // 2
n = int(input())
arr = [0 for i in range(26)]
arr1 = [0 for i in range(26)]
for i in range(n):
	s = input()
	arr[ord(s[0]) - ord('a')] += 1
for i in range(26):
	if arr[i] % 2 == 0:
		arr[i] = arr[i] // 2
		arr1[i] = arr[i]
	else:
		arr[i] = arr[i] // 2
		arr1[i] = arr[i] + 1
ans = 0
for i in range(26):
	ans += givepairs(arr[i])
	ans += givepairs(arr1[i])
print(ans)


def main():
	n = int(input())
	name = []
	for i in range(n):
		name.append(input()[0])
	list1 = {}
	list2 = {}
	for i in range(n):
		if name[i] not in list1:
			list1[name[i]] = 1
		elif name[i] not in list2:
			list2[name[i]] = 1
		elif list1[name[i]] > list2[name[i]]:
			list2[name[i]] += 1
		else:
			list1[name[i]] += 1
	sum = 0
	for i in list1:
		sum += list1[i] * (list1[i] - 1) / 2
	for i in list2:
		sum += list2[i] * (list2[i] - 1) / 2
	print(int(sum))
main()


from math import factorial as f
a = int(input())
b = ''
for x in range(0, a):
	c = input()
	b += c[0]
d = list(set(b))
e = 0
for y in range(0, len(d)):
	i = b.count(d[y])
	l = i // 2
	m = i - l
	if i == 2:
		e += 0
	elif i == 3:
		e += 1
	elif i != 1 and i != 2:
		e += f(l) / (f(2) * f(l - 2)) + f(m) / (f(2) * f(m - 2))
print(int(e))


list = 26 * [0]

def function(Number):
	if Number % 2 == 0:
		a = Number / 2
		return a * (a - 1) / 2 * 2
	else:
		a = (Number + 1) / 2
		return a * (a - 1) / 2 + (a - 1) * (a - 2) / 2
N = int(input())
for i in range(N):
	S = input()
	list[ord(S[0]) - 97] += 1
count = 0
for i in list:
	count += function(i)
print(int(count))


n = int(input())
groups = {}
for i in range(n):
	student = input()
	if student[0] not in groups:
		groups[student[0]] = 1
	else:
		groups[student[0]] += 1
sum = 0
for group in groups.keys():
	first_class = (groups[group] + 1) // 2 - 1
	second_class = groups[group] - (first_class + 1) - 1
	sum += first_class * (first_class + 1) // 2
	sum += second_class * (second_class + 1) // 2
print(sum)


from math import ceil
n = int(input())
l = [None for _ in range(n)]
counts = [0 for _ in range(26)]
for i in range(n):
	l[i] = input()
	counts[ord(l[i][0]) - ord('a')] += 1
ans = 0
for i in range(26):
	ans += counts[i] // 2 * (counts[i] // 2 - 1) // 2
	ans += ceil(counts[i] / 2) * (ceil(counts[i] / 2) - 1) // 2
print(ans)


def add():
	global lis
	lis = []
	for i in range(n):
		lis.append(input())
		lis = sorted(lis)
n = int(input())
add()
counter = 0
for i in range(n):
	for k in range(i + 1, n):
		if i % 2 == k % 2 and lis[i][0] == lis[k][0]:
			counter = counter + 1
print(counter)


d = {}
for i in range(int(input())):
	a = input()[0]
	if a not in d:
		d[a] = 1
	else:
		d[a] += 1
count = 0
for (key, values) in d.items():
	m = values // 2
	n = values // 2 + values % 2
	count += m * (m - 1) // 2
	count += n * (n - 1) // 2
print(count)


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
k = []
for i in range(int(input())):
	name = input()
	k.append(name[0])
coun = 0
sett = set(k)
lis = list(sett)
for i in lis:
	p = k.count(i)
	if p % 2 == 0:
		a = b = p // 2
	else:
		a = p // 2
		b = p // 2 + 1
	coun += int(nCr(a, 2)) + int(nCr(b, 2))
print(coun)


def fun(k):
	res = 0
	for i in range(1, k):
		res += i
	return res
n = int(input())
arr = []
for i in range(n):
	arr.append(input()[0])
s = set(arr)
a = dict()
for i in s:
	a[i] = arr.count(i)
f = []
s = []
for i in a.keys():
	f.append(a[i] // 2)
	s.append(a[i] - a[i] // 2)
ans = 0
for i in f:
	ans += fun(i)
for i in s:
	ans += fun(i)
print(ans)


import sys, math, queue
MOD = 10 ** 9 + 7
n = int(input())
d = {}
for i in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
	else:
		d[s[0]] = 1
ans = 0
for k in d:
	x1 = (d[k] + 1) // 2
	x2 = d[k] - x1
	ans += x1 * (x1 - 1) // 2 + x2 * (x2 - 1) // 2
print(ans)


def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
n = getN()
first = []
for i in range(n):
	first.append(input()[0])
from collections import Counter
c = Counter(first)
ans = 0
for k in c.values():
	a = k // 2
	b = k - a
	ans += a * (a - 1) // 2
	ans += b * (b - 1) // 2
print(ans)


def fact(n):
	if n <= 1:
		return 1
	else:
		return n * fact(n - 1)

def ncr(n, r):
	return fact(n) // (fact(r) * fact(n - r))
n = int(input())
names = []
for _ in range(n):
	temp = input()
	names.append(temp)
names.sort()
dic = {}
for letter in 'qwertyuiopasdfghjklzcxvbnm':
	dic[letter] = 0
for name in names:
	dic[name[0]] += 1
lis = []
for letter in 'qwertyuiopasdfghjklzcxvbnm':
	lis.append(dic[letter])
answer = 0
for elem in lis:
	t1 = elem // 2
	t2 = elem - t1
	answer += ncr(t1, 2) + ncr(t2, 2)
print(answer)


n = int(input())
class1 = {}
class2 = {}
for m in range(n):
	name = str(input())
	if m == 0:
		class1[name[0]] = 1
	elif name[0] in class1:
		if name[0] in class2:
			if class1[name[0]] > class2[name[0]]:
				class2[name[0]] = class2[name[0]] + 1
			else:
				class1[name[0]] = class1[name[0]] + 1
		else:
			class2[name[0]] = 1
	elif name[0] in class2:
		if name[0] in class1:
			if class2[name[0]] > class1[name[0]]:
				class1[name[0]] = class1[name[0]] + 1
			else:
				class2[name[0]] = class2[name[0]] + 1
		else:
			class1[name[0]] = 1
	else:
		class1[name[0]] = 1
sum1 = 0
for j in class1:
	if class1[j] > 1:
		sum1 = sum1 + class1[j] * (class1[j] - 1) / 2
for j in class2:
	if class2[j] > 1:
		sum1 = sum1 + class2[j] * (class2[j] - 1) / 2
print(int(sum1))


dic = {}
for i in range(int(input())):
	l = input()[0]
	if l in dic:
		dic[l] += 1
	else:
		dic[l] = 1

def c(x):
	return x * (x - 1) // 2
s = 0
for v in dic.values():
	s += c(v // 2) + c(v - v // 2)
print(s)


n = int(input())
a = {}
for i in range(26):
	a[i] = 0
for i in range(n):
	s = input()[0]
	a[ord(s) - 97] += 1
count = 0
for i in a:
	b1 = a[i] // 2
	b2 = a[i] - a[i] // 2
	count += b1 * (b1 - 1) // 2
	count += b2 * (b2 - 1) // 2
print(count)


import math
nAlunos = int(input())
classe1 = []
classe2 = []
for i in range(26):
	classe1.append(0)
	classe2.append(0)
for i in range(nAlunos):
	nomeAluno = input()
	if classe1[ord(nomeAluno[0]) - ord('a')] > classe2[ord(nomeAluno[0]) - ord('a')]:
		classe2[ord(nomeAluno[0]) - ord('a')] += 1
	else:
		classe1[ord(nomeAluno[0]) - ord('a')] += 1
conversinhas = 0
for i in range(26):
	if classe1[i] > 1:
		conversinhas += math.factorial(classe1[i]) / (math.factorial(2) * math.factorial(classe1[i] - 2))
	if classe2[i] > 1:
		conversinhas += math.factorial(classe2[i]) / (math.factorial(2) * math.factorial(classe2[i] - 2))
print(int(conversinhas))


n = int(input())
a = sorted([input()[0] for q in range(n)])
s = [1]
for q in range(1, len(a)):
	if a[q] == a[q - 1]:
		s[-1] += 1
	else:
		s.append(1)
ans = 0
for q in s:
	ans += q // 2 * (q // 2 - 1) // 2 + (q + 1) // 2 * ((q + 1) // 2 - 1) // 2
print(ans)


from collections import defaultdict
counts = defaultdict(int)
fac = [1] * 101
for i in range(2, 101):
	fac[i] = i * fac[i - 1]

def pairs(x):
	return fac[x] // fac[x - 2] // 2
t = 0
n = int(input())
for i in range(n):
	s = input()
	counts[s[0]] += 1
for (k, v) in counts.items():
	if v >= 2:
		x = v // 2
		t += pairs(x)
		t += pairs(v - x)
print(t)


from math import factorial
f = factorial
n = int(input())
a = [0] * 30
for i in range(n):
	s = input()
	a[ord(s[0]) - 97] += 1
ans = 0
for x in a:
	if x > 3:
		l = x // 2
		r = x - l
		ans += f(l) // (2 * f(l - 2))
		ans += f(r) // (2 * f(r - 2))
	elif x > 2:
		ans += 1
print(ans)


n = int(input())
pairs = 0
a = []
for _ in range(n):
	i = input()
	a.append(i[0])
arr = [0] * 26
for i in range(len(a)):
	arr[ord(a[i]) - 97] += 1
for i in range(len(arr)):
	n = arr[i] // 2
	m = arr[i] - n
	if n == 1 and m == 1:
		pairs += 0
	elif n == 1:
		pairs += m * (m - 1) // 2
	elif m == 1:
		pairs += n * (n - 1) // 2
	else:
		pairs += m * (m - 1) // 2 + n * (n - 1) // 2
print(pairs)


from math import *
n = int(input())
l = []
s = []
for i in range(n):
	t = input()
	t = t[0]
	l.append(t)
l = sorted(l)
pair = 0
i = 0
while i < len(l):
	j = i
	tmp = 0
	while j < len(l) and l[i] == l[j]:
		j += 1
		tmp += 1
	ow = tmp // 2
	tmp = tmp - ow
	pair += ow * (ow - 1) // 2
	pair += tmp * (tmp - 1) // 2
	i = j
print(pair)


n = int(input())
mark = [0 for _ in range(26)]
for i in range(n):
	next = input()
	mark[ord(next[0]) - 97] += 1
t = 0
for v in mark:
	if v > 2:
		a1 = (v + 1) // 2
		a2 = v // 2
		t += a1 * (a1 - 1) // 2 + a2 * (a2 - 1) // 2
print(t)


def RL():
	return list(map(int, input().split()))
mod = 1000000007
from collections import Counter
from math import factorial
N = int(input())
dic = {}
for i in range(N):
	s = input()
	dic[s[0]] = dic.get(s[0], 0) + 1
res = 0

def com(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m))
for i in dic:
	if dic[i] < 3:
		continue
	if dic[i] // 2 > 1:
		res += com(dic[i] // 2, 2)
	res += com(dic[i] - dic[i] // 2, 2)
print(int(res))


from collections import defaultdict
import math
import operator as op
from functools import reduce
from itertools import combinations

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
num_students = int(input())
students = defaultdict(int)
for _ in range(num_students):
	student_name = input()
	students[student_name[0]] += 1
chatty_pairs = 0
for key in students:
	num_in_A = students[key] // 2
	num_in_B = students[key] - num_in_A
	chatty_pairs += math.floor(nCr(num_in_A, 2)) + math.floor(nCr(num_in_B, 2))
print(chatty_pairs)


from math import floor, ceil
n = int(input())
l = []
for i in range(n):
	l.append(input()[0])
m = {x: 0 for x in l}
for i in l:
	m[i] += 1
minp = 0
for i in m:
	minp += floor(m[i] / 2) * (floor(m[i] / 2) - 1) / 2 + ceil(m[i] / 2) * (ceil(m[i] / 2) - 1) / 2
print(int(minp))


from collections import defaultdict
n = int(input())
m = defaultdict(int)
for i in range(n):
	s = input()
	m[s[0]] += 1
k = 'abcdefghijklmnopqrstuvwxyz'
ans = 0
for i in k:
	d = m[i]
	if d % 2 != 0:
		ans += d // 2
	for j in range(1, d // 2):
		ans += 2 * j
print(ans)


n = int(input())
s = []
first = []
distinct = []
for i in range(n):
	s.append(input())
	first.append(s[i][0])
	if s[i][0] not in distinct:
		distinct.append(s[i][0])
count = 0
for i in distinct:
	k = first.count(i)
	if k % 2 == 0:
		count += k // 2 * (k // 2 - 1)
	else:
		count += k // 2 * (k // 2)
print(count)


n = int(input())
a = []
for _ in range(n):
	a.append(input()[0])
q = 0

def f(x):
	return x * (x - 1) // 2
for i in set(a):
	r = a.count(i)
	if r % 2 == 0:
		q += 2 * f(r // 2)
	else:
		q += f(r // 2) + f(r // 2 + 1)
print(q)