fun main(args: Array<String>)
{
    val n = readInt()
    val arr = Array<String>(n, { readString().toList().sorted().joinToString("") } )

    val mm = mutableMapOf<String, Long>()
    for (s in arr)
    {
        val v = if (mm.containsKey(s)) mm[s]!!.plus(1L) else 0L
        mm.put(s, v)
    }

    println(mm.values.map{ it * (it + 1) / 2 }.reduce{ acc, item -> acc + item })
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!
