object Main extends App {
    val n = io.StdIn.readInt()
    var str = Array.ofDim[String](n)
    var ans = 0L
    for (i <- 0 until n){
        val in = io.StdIn.readLine()
        val sorted = in.sorted
        str(i) = sorted
    }
    for (i <- 0 until n)
        for (j <- i+1 until n)
            if(str(i) == str(j))
                ans += 1

    print(ans)
}