N = int(raw_input())
c,d = 0,{}
for _ in xrange(0,N):
	line = raw_input()
	key = ''.join(sorted(list(line)))
	if d.has_key(key): d[key].append(line)
	else: d[key] = [line]
for v in d.itervalues():
	if len(v)<2: continue
	e = {}
	for vi in v:
		if e.has_key(vi): e[vi]+=1
		else: e[vi] = 1
	for f in e.iterkeys():
		if e.has_key(f[::-1]) and f!=f[::-1]: c+=e[f]*e[f[::-1]]
print c/2