"use strict";
    
// 組み合わせ（nCr）列挙ではなく計算のみ
const permutation = (n, r) => {
    let res = 1;
    
    for(let i=0; i<r; i++) {
        res *= n - i;
    }
    
    return res;
}
 
const nCr = (n, r) => {
    return permutation(n, r) / permutation(r, r);
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const S = arg.slice(1, N + 1);
    
    const map = {};
    
    for(let i=0; i<N; i++) {
        let temp = S[i].split("").sort().join("");
        
        // console.log(temp)
        
        if(map[temp]) {
            map[temp]++;
        } else {
            map[temp] = 1;
        }
    }
    
    let answer = 0;
    
    for(let key in map) {
        if(map[key] >= 2) {
            answer += nCr(map[key], 2);
        }
    }
    
    console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));