#require 'pp'
#require 'set'

n = gets.chomp!.to_i
s_n = []
n.times do |i|
    s = gets.chomp!.chars.sort.join
    s_n << s
end

$memo = {
    1 => 0,
    2 => 1,
}

def count(n)
    return $memo[n] if $memo[n]

    $memo[n] = (n - 1) + count(n-1)
    return $memo[n]
end

s = s_n.group_by{|x| x}
sum = 0
s.each do |a, b|
    sum += count(b.length)
end

puts sum
