n = gets.chomp.to_i
s = []
n.times{s << gets.chomp}
cnt = 0
for i in 0..(n-1)
    for j in (i+1)..(n-1)
        if s[i].chars.sort == s[j].chars.sort
            cnt += 1
        end
    end
end
puts cnt