n = gets.to_i
ss = n.times.map { gets.chomp.chars.sort.join }

hash = Hash.new { |h, k| h[k] = [] }

ss.each_with_index do |s, i|
  hash[s] << i
end

ans = hash.each.inject(0) { |r, (_k, v)| r + v.combination(2).count }
puts ans
