line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

N = line[0].to_i

def string_sort(s)
  a = []
  for i in 1..s.length do
    a.push(s[i-1])
  end
  a = a.sort
  result = ""
  for i in 1..s.length do
    result += a[i-1]
  end
  return result
end

a = []
for i in 1..N do
  a.push(string_sort(line[i]))
end
  
a = a.sort

count = 0
overlap = [1]
for i in 1..N-1 do
  if a[i-1] == a[i] then
    overlap[count] += 1
  else
    count += 1
    overlap[count] = 1
  end
end
  
result = 0
overlap.each do |i|
  result += i * (i-1) / 2
end

print result