object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val s = List.fill(n)(sc.next.sorted)
    sc.close()

    val ans = s.distinct.foldLeft(0)((x, y) => {
      var a = 0
      (0 until s.count(_ == y)).foreach(i => a += i)
      x + a
    })
    println(ans)
  }
}