n = gets.to_i
counts = Hash.new(0)
while line = gets
    line = line.chomp
    count = Hash.new(0)
    words = line.split(//)
    words.each do |w|
        count[w] += 1
    end
    counts[line] = count
end

ary = []
counts.each_value do |val| 
    ary.push(val)
end

c = 0
i = 0
while i < ary.length do
    (1..ary.length).each do |n|
        c = c + 1 if ary[i] == ary[i+n]
    end
    i = i + 1
end

puts c