# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
$hh = {}
while l = $stdin.gets do
  if lc == 0
  else
    tmp = l.chomp.split("").sort.join
    $hh[tmp] = 0 if $hh[tmp] == nil
    $hh[tmp] += 1
  end
  lc += 1
end

ans = 0
$hh.each do |k, v|
  if v >= 2
    ans += v*(v-1)/2
  end
end

puts ans
