n = gets.to_i - 1
arr = Array.new
while line = $stdin.gets
arr << line.chomp.split("")
end
arr.each{|item|
item.sort!}
ans = 0
n.times{|t|
(n-t).times{|r|
  if arr[t] == arr[r+t+1] then
    ans +=1
  end


}
}
p ans