from collections import defaultdict
d=defaultdict(lambda:[0,0])
n=int(raw_input())
for e in xrange(n):
	s=raw_input()
	if s in d or s[::-1] in d:
		if s in d:d[s][0]+=1
		elif s[::-1] in d:d[s[::-1]][1]+=1
	else:d[s][0]=1
summ=0
for e in d:
	if d[e][0] and d[e][1]:
		summ+=d[e][0]*d[e][1]
print summ