n = gets.chomp.to_i
s_arr = n.times.map{gets.chomp.split("").sort.join("")}

max = 0
hash = {}
s_arr.each do |s|
  hash[s] ||= 0
  hash[s] += 1
  max = hash[s] if max < hash[s]
end

cache = {}
cache[0] = 1
tmp = 1
(1..max).each do |t|
  tmp *= t
  cache[t] = tmp
end

count = 0
hash.each do |s, c|
  next if c <= 1
  count += (cache[c] / 2 * cache[c-2])
end

puts count
