object Main extends App {
    var n = io.StdIn.readInt
    var ss = Range(0, n).map(t=>io.StdIn.readLine.split("").sorted.mkString(""))
    val words = collection.mutable.Map[String, Int]()
    var ans:Long = 0
    ss.foreach{s=>
        ans += words.getOrElse(s, 0)
        words += s -> (words.getOrElse(s, 0)+1) // map
    }
    //println(words.values.map{x=>toLong*(x.toLong-1L)/2}.sum)
    println(ans)
}