function main(input) {
	var splitted = input.split("\n")
	var num = Number(splitted[0])
	var list = splitted
		.filter((s, i) => i > 0)
		.map(s => Array.from(s).sort().join(''))
		.sort()
	var count = 0;
	var pasts = [list[0]]
	for (var i = 1; i < list.length; i++) {
		pasts.forEach(str => {
			if (list[i] === str) count++
		})
		pasts.push(list[i])
	}
	console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));