

fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val words = (1..n).map { readLine()!!.toList().sorted().joinToString("") }.sorted()
    var prev = words[0]
    var start = 0
    var ans = 0L
    for(i in (1 until n)) {
        if(prev == words[i]) {
            continue
        }
        val cnt = i - start.toLong()
        if(cnt >= 2) {
            ans += (cnt*(cnt-1)/2)
        }
        start = i
        prev = words[i]
    }
    val cnt = n - start.toLong()
    if(cnt >= 2) {
        ans += (cnt*(cnt-1)/2)
    }
    println(ans)
}

