#!/usr/bin/env ruby
n, = ARGF.gets.split.map {|x| x.to_i}
hash1 = Hash.new(0)
(1..n).map do
  hash2 = Hash.new(0)
  ARGF.gets.chomp.each_codepoint do |ch|
    hash2[ch] += 1
  end
  hash1[hash2.hash] += 1
end
puts hash1.values.map{|v|(v-1)*v/2}.sum
