n = gets.chomp("").to_i

s = Array.new
n.times do |i|
  s << gets.chop.split("").sort
end

count = 0
n.times do |i|
  (n-i-1).times do |w|
    if (s[i] - s[w+1+i]).length == 0
      count += 1
    end
  end
end

puts count
