fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val strs = Array(N, { i -> readLine()!!.toCharArray().sorted().toString() }).sorted()

    var cnt:Long = 0
    var ren:Long = 1
    for(i in 1 until N) {
        if (strs[i] == strs[i-1]) {
            ren += 1
        } else {
            cnt += (ren * (ren-1) / 2).toLong()
            ren = 1
        }
    }
    cnt += (ren * (ren-1) / 2).toLong()
    println(cnt)
}