fun main(arg: Array<String>) {
    val N = nextInt()
    val S = Array<String>(N) {""}
    repeat(N) {
        S[it] = next().toCharArray().sorted().joinToString(separator = "")
    }
    val A = S.groupBy{ it }.map{ Pair(it.key, it.value.size) }
    var ans = 0L
    A.forEach { ans += ((it.second.toLong() * (it.second.toLong() - 1)) / 2) }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
