facto_memo = {}

def factorial(x, memo)
  if memo.include?(x)
    return memo[x]
  elsif x == 0
    memo[0] = 1
    return 1
  else
    f = x * factorial(x - 1, memo)
    memo[x] = f
    return f
  end
end

def combi(p, q, memo)
  return factorial(p, memo) / factorial(q, memo) / factorial(p-q, memo)
end

n = gets.to_i
h = {}
for i in 0...n do
  s = gets.chomp.split("").sort.join("")
  if h.include?(s)
    h[s] += 1
  else
    h[s] = 1
  end
end

count = 0
h.each do |k, v|
  if v >= 2
    count += combi(v, 2, facto_memo)
  end
end
puts count
