_ = gets
h = Hash.new(0)
$<.each do |line|
  l = line.chars.sort.join
  h[l] += 1
end
count = 0
h.values.each do |v|
  next if v <= 1
  count += ((v-1)..v).reduce(&:*)/((1..2).reduce(&:*))
end
p count