import sys
N = sys.stdin.readline()
strings = {}
occurences = {}
for x in range(int(N)):
	n = sys.stdin.readline().strip().lower()
	if not n in occurences:
		occurences[n] = 1
	else:
		occurences[n] += 1
	if n[-1::-1] in occurences:
		#print "--" , strings
		if n[-1::-1] in strings:
			strings[n[-1::-1]] += occurences[n[-1::-1]]
		else:
			strings[n[-1::-1]] = occurences[n[-1::-1]]
#print strings
#print occurences
print sum(strings.values())