#!/usr/bin/env ruby
n, = ARGF.gets.split.map {|x| x.to_i}
s = (1..n).map{ ARGF.gets.split('').sort.join }
sum = 0
while s1 = s.pop
  len1 = s.length
  s.delete(s1)
  len2 = s.length
  count = len1 - len2
  sum += (count + 1) * count / 2
end
puts sum
