local num = tonumber(io.read())
local input = {}

for i = 1, num do
  local v = table.pack(string.byte(io.read(), 1, 10))
  table.sort(v)
  v = string.char(table.unpack(v))
  if input[v] ~= nil then
    input[v] = input[v] + 1
  else
    input[v] = 1
  end
end

local t = 0
for k, v in pairs(input) do
  t = t + v * (v - 1) // 2
end
print(t)