import java.math.BigDecimal

/**
 * @author kojin15.
 */

fun main(args: Array<String>) {
    val N = readInt()
    val s = Array(N) { String(readString().toCharArray().sorted().toCharArray()) }
    val map = mutableMapOf<String, Long>()
    map[s[0]] = 1L
    for (i in 1 until N) {
        if (map.containsKey(s[i])) {
            map[s[i]] = map[s[i]]!! + 1L
        } else map[s[i]] = 1L
    }
    var result = 0L
    for ((t, u) in map) {
        result += (u * (u - 1)) / 2
    }
    println(result)
}

//in--------------------------------------------------------------------------------------------------------------------
fun readString(): String = readLine()!!
fun readStringArrayH(): Array<String> = readString().split(" ").let { Array(it.size) { n -> it[n] } }
fun readStringArrayV(n: Int): Array<String> = Array(n) { readString() }

fun readInt(): Int = readString().toInt()
fun readIntArrayH(): IntArray = readString().split(" ").map(String::toInt)
    .let { IntArray(it.size) { n -> it[n] } }
fun readIntArrayV(n: Int): IntArray = IntArray(n) { readInt() }

fun readLong(): Long = readString().toLong()
fun readLongArrayH(): LongArray = readString().split(" ").map(String::toLong)
    .let { LongArray(it.size) { n -> it[n] } }
fun readLongArrayV(n: Int): LongArray = LongArray(n) { readLong() }

fun readDouble(): Double = readString().toDouble()
fun readDoubleArrayH(): DoubleArray = readString().split(" ").map(String::toDouble)
    .let { DoubleArray(it.size) { n -> it[n] } }
fun readDoubleArrayV(n: Int): DoubleArray = DoubleArray(n) { readDouble() }

//out-------------------------------------------------------------------------------------------------------------------
fun printBool(bool: Boolean, yes: String, no: String) = println(if (bool) yes else no)
fun printYn(bool: Boolean) = printBool(bool, "Yes", "No")
fun printYN(bool: Boolean) = printBool(bool, "YES", "NO")
fun printPossible(bool: Boolean) = printBool(bool, "Possible", "Impossible")
fun printYay(bool: Boolean) = printBool(bool, "Yay!", ":(")

fun Double.toExactString(): String = BigDecimal.valueOf(this).toPlainString()

//string----------------------------------------------------------------------------------------------------------------
operator fun String.get(start: Int, endInclusive: Int): String = this.substring(start, endInclusive + 1)
operator fun String.get(range: IntRange): String = this.substring(range)

fun String.replace(replace: (Char) -> Char): String {
    return String(CharArray(this.length) { replace(this[it]) })
}

//cast------------------------------------------------------------------------------------------------------------------
fun int(n: Number) = n.toInt()
fun long(n: Number) = n.toLong()
fun double(n: Number) = n.toDouble()
fun float(n: Number) = n.toFloat()

//math------------------------------------------------------------------------------------------------------------------
tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b
fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b

var MOD: Int = 1000000007 //素数推奨
class ModInt(x: Int) {
    val x: Int = x modP MOD

    val mod: Int get() = MOD
    val inverse: ModInt get() = this.pow(MOD - 2)

    val factorial: ModInt get() = if (this > 0) this * (this - 1).factorial else ModInt(1)
    val doubleFactorial: ModInt get() = if (this > 1) this * (this - 2).doubleFactorial else ModInt(1)

    operator fun unaryMinus(): ModInt = ModInt(-x)

    operator fun inc(): ModInt = ModInt(x + 1)
    operator fun dec(): ModInt = ModInt(x - 1)

    operator fun plus(other: ModInt): ModInt = ModInt(x + other.x)
    operator fun plus(other: Int): ModInt = this.plus(ModInt(other))

    operator fun minus(other: ModInt): ModInt = this + (-other)
    operator fun minus(other: Int): ModInt = this.minus(ModInt(other))

    operator fun times(other: ModInt): ModInt = ModInt(x * other.x)
    operator fun times(other: Int): ModInt = this.times(ModInt(other))

    operator fun div(other: ModInt): ModInt = this * other.inverse
    operator fun div(other: Int): ModInt = this.div(ModInt(other))

    infix fun pow(n: Int): ModInt = ModInt(this.x.powM(n, MOD))

    operator fun compareTo(other: ModInt) = this.x.compareTo(other.x)
    operator fun compareTo(other: Int) = this.compareTo(ModInt(other))

    override operator fun equals(other: Any?): Boolean {
        if (other is ModInt) return this.x == other.x
        return this.x == other
    }

    override fun hashCode(): Int {
        return x
    }

    override fun toString(): String {
        return this.x.toString()
    }
}
operator fun Int.plus(other: ModInt): ModInt = ModInt(this).plus(other)
operator fun Int.minus(other: ModInt): ModInt = ModInt(this).minus(other)
operator fun Int.times(other: ModInt): ModInt = ModInt(this).times(other)
operator fun Int.div(other: ModInt): ModInt = ModInt(this).div(other)
operator fun Int.compareTo(other: ModInt) = ModInt(this).compareTo(other)

infix fun Int.modP(mod: Int): Int {
    val y = this % mod
    return if (y < 0) y + mod else y
}

infix fun Int.pow(n: Int): Int = when {
    n == 0 -> 1
    n % 2 == 0 -> pow(n / 2).let { it * it }
    else -> this * pow(n - 1)
}

fun Int.powM(n: Int, m: Int): Int = when {
    n == 0 -> 1
    n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m
    else -> ((this % m) * (pow(n - 1) % m)) % m
}

//kotlin.math v1.2------------------------------------------------------------------------------------------------------
val LN2: Double = ln(2.0)
val epsilon: Double = Math.ulp(1.0)
val taylor_2_bound = Math.sqrt(epsilon)
val taylor_n_bound = Math.sqrt(taylor_2_bound)
val upper_taylor_2_bound = 1 / taylor_2_bound
val upper_taylor_n_bound = 1 / taylor_n_bound

fun sin(x: Double): Double = Math.sin(x)
fun cos(x: Double): Double = Math.cos(x)
fun tan(x: Double): Double = Math.tan(x)
fun asin(x: Double): Double = Math.asin(x)
fun acos(x: Double): Double = Math.acos(x)
fun atan(x: Double): Double = Math.atan(x)
fun atan2(y: Double, x: Double): Double = Math.atan2(y, x)
fun sinh(x: Double): Double = Math.sinh(x)
fun cosh(x: Double): Double = Math.cosh(x)
fun tanh(x: Double): Double = Math.tanh(x)

fun asinh(x: Double): Double =
    when {
        x >= +taylor_n_bound ->
            if (x > upper_taylor_n_bound) {
                if (x > upper_taylor_2_bound) {
                    // approximation by laurent series in 1/x at 0+ order from -1 to 0
                    Math.log(x) + LN2
                } else {
                    // approximation by laurent series in 1/x at 0+ order from -1 to 1
                    Math.log(x * 2 + (1 / (x * 2)))
                }
            } else {
                Math.log(x + Math.sqrt(x * x + 1))
            }
        x <= -taylor_n_bound -> -asinh(-x)
        else -> {
            // approximation by taylor series in x at 0 up to order 2
            var result = x;
            if (Math.abs(x) >= taylor_2_bound) {
                // approximation by taylor series in x at 0 up to order 4
                result -= (x * x * x) / 6
            }
            result
        }
    }
fun acosh(x: Double): Double =
    when {
        x < 1 -> Double.NaN

        x > upper_taylor_2_bound ->
            // approximation by laurent series in 1/x at 0+ order from -1 to 0
            Math.log(x) + LN2

        x - 1 >= taylor_n_bound ->
            Math.log(x + Math.sqrt(x * x - 1))

        else -> {
            val y = Math.sqrt(x - 1)
            // approximation by taylor series in y at 0 up to order 2
            var result = y
            if (y >= taylor_2_bound) {
                // approximation by taylor series in y at 0 up to order 4
                result -= (y * y * y) / 12
            }

            Math.sqrt(2.0) * result
        }
    }
fun atanh(x: Double): Double {
    if (Math.abs(x) < taylor_n_bound) {
        var result = x
        if (Math.abs(x) > taylor_2_bound) {
            result += (x * x * x) / 3
        }
        return result
    }
    return Math.log((1 + x) / (1 - x)) / 2
}

fun hypot(x: Double, y: Double): Double = Math.hypot(x, y)
fun sqrt(x: Double): Double = Math.sqrt(x)
fun exp(x: Double): Double = Math.exp(x)
fun expm1(x: Double): Double = Math.expm1(x)

fun log(x: Double, base: Double): Double {
    if (base <= 0.0 || base == 1.0) return Double.NaN
    return Math.log(x) / Math.log(base)
}
fun ln(x: Double): Double = Math.log(x)
fun log10(x: Double): Double = Math.log10(x)
fun log2(x: Double): Double = Math.log(x) / LN2
fun ln1p(x: Double): Double = Math.log1p(x)

fun ceil(x: Double): Double = Math.ceil(x)
fun floor(x: Double): Double = Math.floor(x)
fun truncate(x: Double): Double = when {
    x.isNaN() || x.isInfinite() -> x
    x > 0 -> floor(x)
    else -> ceil(x)
}
fun round(x: Double): Double = Math.rint(x)

fun abs(x: Double): Double = Math.abs(x)
fun sign(x: Double): Double = Math.signum(x)
fun min(a: Double, b: Double): Double = Math.min(a, b)
fun max(a: Double, b: Double): Double = Math.max(a, b)
val Double.absoluteValue: Double get() = Math.abs(this)
val Double.sign: Double get() = Math.signum(this)

fun abs(n: Int): Int = Math.abs(n)
fun min(a: Int, b: Int): Int = Math.min(a, b)
fun max(a: Int, b: Int): Int = Math.max(a, b)
val Int.absoluteValue: Int get() = Math.abs(this)
val Int.sign: Int get() = when {
    this < 0 -> -1
    this > 0 -> 1
    else -> 0
}

fun abs(n: Long): Long = Math.abs(n)
fun min(a: Long, b: Long): Long = Math.min(a, b)
fun max(a: Long, b: Long): Long = Math.max(a, b)
val Long.absoluteValue: Long get() = Math.abs(this)
val Long.sign: Int get() = when {
    this < 0 -> -1
    this > 0 -> 1
    else -> 0
}

Measured memory_bytes: 57992