#require 'pp'
#require 'set'

n = gets.chomp!.to_i
s_n = []
ana = {}
n.times do |i|
    s = gets.chomp!.chars.sort.join
    ana[s] ||= 0
    ana[s] += 1
end

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

3.upto(10 ** 5) do |i|
    memo[i] = (i - 1) + memo[i - 1]
end

sum = 0
ana.each do |a, b|
    sum += memo[b]
end

puts sum
