ans = 0
n = gets.to_i
ss = readlines.map(&:chomp).map(&:chars).map(&:sort).map(&:join)
hash = {}
for s in ss do
	hash[s] = hash.fetch(s, 0) + 1
end
hash.each_value do |v|
	ans += v * (v - 1) / 2
end
print(ans)
#print(hash)
