attrs = $stdin.gets.chomp.split(' ').map(&:to_i)
N = attrs[0]
arr = []
i = 0
while i < N
  arr << $stdin.gets.chomp
  i += 1
end

arr.sort!

res = 0
j = 0
used_arr = []
while j < N
  target = arr[j]
  arr.delete_at(j)
  arr.each do |a|
    if (a.chars.sort == target.chars.sort) && !used_arr.include?([a, target].sort)
      used_arr << [a, target].sort
      res += 1
    end
  end
  arr.insert(j, target)
  j += 1
end

puts res
