local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end

local function nC2(n)
    if n < 2 then
        return 0
    end
    return n * (n-1) // 2
end
---
local N, _ = io.read("n", "l")
local sorted_dic = {}
for i=1,N do
    local s = io.read("l")
    local s_tbl = str2tbl(s)
    table.sort(s_tbl)
    local s_sorted = table.concat(s_tbl, "")
    --print(s_sorted)
    sorted_dic[s_sorted] = (sorted_dic[s_sorted] or 0) + 1
end
local ans = 0
for k,v in pairs(sorted_dic) do
    ans = ans + nC2(v)
end
print(ans)