s = readlines.map(&:chomp)
n = s[0].to_i
s[1] = s[1].chars.sort.join
ans = 0
count = 2

s[1..n].each do |i|
  (count..n).each do |j|
    if i.chars.sort.join == s[j].chars.sort.join
      ans += 1
      puts s[j]
    end
  end
  count = count + 1
end

puts ans