n = gets.chomp.to_i
s = []

for i in 1..n do
    word = gets.chomp.split("")
    tar = word.sort.join
    head = 0
    tail = s.size-1
    find = false
    if s.empty?
        s.push([tar,1])
    else
        while head <= tail 
            mid = ((head+tail)/2.0).ceil
            # print head," ", mid," ", tail, "\n"
            # print tar," ",s[mid][0],"\n"
            # puts tar > s[mid][0]
            if tar == s[mid][0]
                break
            elsif tar > s[mid][0]
                head = mid + 1
            else
                tail = mid - 1
            end
        end
        mid = ((head+tail)/2.0).ceil
        if mid >= s.size 
            s.push([tar,1])
        elsif s[mid][0].eql?(tar)
            s[mid][1] += 1
        else
            s.insert(mid,[tar,1])
        end
    end
end


sum = 0
for i in 1..s.size
    num = s[i-1][1]
    sum += num*(num-1)/2
end
p sum
