'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	let cnt = 0

	for (let i = 0; i < N; i++) {
		const s1 = args[i + 1][0].split('').sort((a, b) => {
			if (a < b) return -1
			else if (a > b) return 1
			else return 0
		}).join('')

		for (let j = i + 1; j < N; j++) {
			const s2 = args[j + 1][0].split('').sort((a, b) => {
				if (a < b) return -1
				else if (a > b) return 1
				else return 0
			}).join('')

			if (s1 === s2) cnt++
		}
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
