require "pp"

n = gets.to_i
s = []
n.times {s.push(gets.chomp)}

c = s.map{|str| str.split("").sort.join}.combination(2)
puts c.map{|arr| arr.uniq
  if arr[0] == arr[1]
    1
  else
    0
  end
}.inject(:+)
