lines = readlines
n = lines[0].chomp.to_i

arr = []
for i in 1..n do
  arr << lines[i].chomp.chars.sort_by! {|a, b|a}
end

count_arr = []

while arr != []
  counter = 0
  stack = arr.shift
  arr.each_with_index do |ar, i|
    if stack == ar
      arr.slice!(i)
      counter += 1
    end
  end
  count_arr << counter
end

result = 0
count_arr.each do |culc|
  result += (culc + 1) * culc / 2
end

p result