n = gets.to_i
a = n.times.map{gets.chomp}

p a.map!{|s| s.split("").sort}.group_by(&:itself).map{ |key, value| [key, value.count] }.to_h.values.select{|x| x>1}.inject(0){|i, j| i+=(j>1 ? j*(j-1)/2 : 0)}