dic = {}

for n in range(input()):
	x = raw_input()
	if x not in dic:
		dic[x] = 0
	dic[x]+=1

ans = 0

for s in dic:
	rs = s[::-1]
	if s==rs:
		ans += dic[s]*( dic[s]-1 )
	else:
		if rs in dic:
			ans += dic[s]*dic[rs]

print ans/2