$cc_val = Array.new(100000+1,nil)
$cc_val[0] = 0
$cc_val[1] = 0
def cc_calc(n)
    unless $cc_val[n]
        $cc_val[n] = cc_calc(n-1) + n-1
    end
    $cc_val[n]
end

def cc
    n = gets.chomp.to_i
    dic = {}
    n.times do
        st = gets.chomp.scan(/./).sort.join
        if dic.has_key?(st)
            dic[st] += 1
        else
            dic[st] = 1
        end
    end

    cnt = 0
    dic.each_pair {|k, v|
        cnt += cc_calc(v)
    }
    puts cnt
end

cc
