import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val N = readInt()

  val words = for (_ <- 1 to N) yield {
    readLine.sorted
  }

  @scala.annotation.tailrec
  def countAnagrams(buf: mutable.Buffer[String], n: Int): (mutable.Buffer[String], Int) = {
    val counts = buf.count(_ == buf.head)
    val c = if (counts != 1) n + counts else n

    val filtered = buf.filter(_ != buf.head)
    if (filtered.nonEmpty) {
      countAnagrams(filtered, c)
    } else {
      (filtered, c)
    }
  }

  val ans = countAnagrams(words.toBuffer, 0)._2
  println(ans)

}
