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)
    var result =  s.map{
        _.split("")
        .sorted
        .mkString("")
      }
      .sorted
      .groupBy(s => s)
      .values
      .map { v => v.size * (v.size -1) / 2 }
      .sum
    println(result);
  }
}
