from collections import Counter
a = Counter()
b = set()
ans = 0
for _ in range(int(raw_input())):
	a[raw_input().strip()] += 1
for k, v  in a.iteritems():
	if k in b:
		continue
	rs = k[::-1]
	if rs in a:
		ans += v * a[rs]
		b.add(rs)
print ans