import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main extends App {
  val num = readInt()
  val input = for (e <- 0 until num) yield readLine()

  val sorted = input.map(_.toSeq.sorted.unwrap).toList

  def count(ls: List[String], n: Int): (List[String], Int) = ls match {
    case Nil => (Nil, n)
    case h :: Nil => (ls, n)
    case h :: tail => count(tail.filterNot(e => e == h), n + sorted.tail.count(_ == sorted.head))
  }

  val ans = count(sorted, 0)
  println(ans._2)
}
