n = gets.to_i
s = []
n.times do
    input = gets.chomp
    s << input
end

count = 0
n.times do |i|
    ((i+1)..(n-1)).each do |j|
        10.times do |k|
            break if s[i].count(s[i][k]) != s[j].count(s[i][k])
            count += 1 if k == 9
        end
    end
end

puts count