fun main(args: Array<String>) = yorukatsu19c()

fun yorukatsu19c() {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toCharArray().sorted() }

    val answer = sList.groupBy { it }.map { it.value.size.toLong() }
        .fold(0L) { acc, l -> acc + (l - 1) * l / 2 }

    println(answer)
}
