fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toCharArray() }
    sList.forEach { it.sort() }
    val sortedList = sList.map { it.joinToString() }.sorted()

    val groupedMap = sortedList.groupBy { it }

    val count = groupedMap.map { calcCombination(it.value.size.toLong()) }.sum()

    println(count)
}

fun calcCombination(n: Long): Long {
    return if (n == 1.toLong()) {
        0
    } else {
        n - 1 + calcCombination(n - 1)
    }
}
