local n = io.read("*n", "*l")
local map = {}
for i = 1, n do
  local str = io.read()
  local t = {}
  for i = 1, 10 do
    table.insert(t, str:sub(i, i))
    table.sort(t)
  end
  local sorted = table.concat(t)
  if not map[sorted] then map[sorted] = 1
  else map[sorted] = map[sorted] + 1
  end
end
local ret = 0
for k, v in pairs(map) do
  ret = ret + (v * (v - 1)) // 2
end
print(ret)
