fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val strings = mutableMapOf<String, Long>()
    
    for (i in 0 until N) {
        val s = readInputLine().toCharArray()
        s.sort()
        val sorted = s.joinToString("")
        val cnt = strings.get(sorted) ?: 0L
        strings.put(sorted, cnt + 1L)
    }

    var ans = 0L
    
    for ((k, v) in strings.toList()) {
        ans += (v.toLong() - 1L) * (v.toLong()) / 2L
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
