fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    var s = mutableListOf<String>()
    (1..N).forEach {
        val str = readLine()!!
        s.add(str.toCharArray().sorted().toString())
    }


    val countMap = hashMapOf<String, Long>()
    s.forEach {
        val string = it.toString()
        if (countMap.contains(string)) {
            countMap[string] = countMap[string]!! + 1L
        } else {
            countMap[string] = 1
        }
    }

    var answer = 0L
    countMap.entries
            .filter { it.value > 1 }
            .forEach {
                val size = it.value
                answer += size * (size - 1L) / 2L
            }
    println(answer)
}