import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc String tmp[] = new String[10]; tmp new String[10] 10 String tmpStr; tmpStr Map<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() long answer = 0; answer 0 for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		} {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		} tmpStr = sc.next() tmpStr sc.next() sc.next sc tmp = tmpStr.split("") tmp tmpStr.split("") tmpStr.split tmpStr "" Arrays.sort(tmp) Arrays.sort Arrays tmp if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			} map.containsKey(Arrays.toString(tmp)) map.containsKey map Arrays.toString(tmp) Arrays.toString Arrays tmp {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1) map.put map Arrays.toString(tmp) Arrays.toString Arrays tmp (int)map.get(Arrays.toString(tmp)) + 1 (int)map.get(Arrays.toString(tmp)) map.get map Arrays.toString(tmp) Arrays.toString Arrays tmp 1 {
				map.put(Arrays.toString(tmp), 1);
			} map.put(Arrays.toString(tmp), 1) map.put map Arrays.toString(tmp) Arrays.toString Arrays tmp 1 for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		} String key map.keySet() map.keySet map {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		} {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		} long n = map.get(key); n map.get(key) map.get map key answer += (n * (n - 1)) / 2 answer (n * (n - 1)) / 2 (n * (n - 1)) n (n - 1) n 1 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
}
