if __name__ == '__main__':
	N = int(raw_input())
	ans = 0
	mapi = dict()
	for i in xrange(N):
		s = raw_input()
		r_s = s[::-1]
		ans = ans + mapi[r_s] if r_s in mapi else ans
		#print ans , s , r_s
		if s in mapi:
			mapi[s] = mapi[s] + 1
		else:
			mapi[s] = 1
	print ans