n = gets.to_i
#s = n.times.map { gets.chomp.split('').sort! }.sort
s = Array.new(n){ gets.chomp.chars.sort }.sort
#puts s

#s.sort! {|a,b| a[0] <=> b[0]}
=begin
for i in 0..n-1
  s[i].sort
end
=end
#s.sort[].sort!
#puts s[1]
ans = 0
count=1
for  i in 0..n-2

  if s[i]==s[i+1]
    count+=1
  else
    if count>1
      ans += count * (count-1) / 2
    end
    count=1
  end
end
ans+=count * (count-1) /2 if count>1

puts ans
