N = gets.strip.to_i
ABS = readlines.map {|line| line.strip}
ABS.each_with_index do |str, index|
  ABS[index] = str.split('').sort.join('')
end

count = 0
ABS.group_by{ |e| e }.each do |k,v|
  v.combination(2) do |a, b|
    count += 1
  end
end

puts count