fun main(args: Array<String>) {
    val count = readLine()!!.toInt()
    val list = mutableListOf<List<Char>>()
    repeat(count) {
        list.add(readLine()!!.toCharArray().sorted())
    }
    print(abc137c(list))
}

fun abc137c(list: MutableList<List<Char>>): Long {
    var anagramCount: Long = 0
    
//v1.0では使えない
//    list.groupingBy { it }.eachCount().filter { it.value > 1 }.forEach{
//        for (i in it.value - 1 downTo 1) anagramCount += i }

    list.groupBy { it }.mapValues { it.value.count() }.forEach{
        for (i in it.value - 1 downTo 1) anagramCount += i }

    return anagramCount
}