#include <bits/stdc++.h>
using namespace std;

map<string, long> m;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}
	long r = 0;
	for (auto p : m)
		r += p.second*(p.second - 1) / 2;
	cout << r << endl;
	return 0;
}
