
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[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
} 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[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc String[] S = new String[N]; S new String[N] N for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			S[i] = sc.next();
		} {
			S[i] = sc.next();
		} S[i] = sc.next() S[i] S i sc.next() sc.next sc Map<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() long result = 0; result 0 for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		} {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		} String[] tmp = S[i].split(""); tmp S[i].split("") S[i].split S[i] S i "" Arrays.sort(tmp) Arrays.sort Arrays tmp String s = String.join("", tmp); s String.join("", tmp) String.join String "" tmp if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			} map.containsKey(s) map.containsKey map s {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} result += map.get(s) result map.get(s) map.get map s map.put(s, map.get(s) + 1) map.put map s map.get(s) + 1 map.get(s) map.get map s 1 {
				map.put(s, 1);
			} map.put(s, 1) map.put map s 1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
} 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[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Map<String, Integer> map = new HashMap<String, Integer>();
		long result = 0;

		for (int i = 0; i < N; i++) {
			String[] tmp = S[i].split("");
			Arrays.sort(tmp);
			String s = String.join("", tmp);

			if (map.containsKey(s)) {
				result += map.get(s);
				map.put(s, map.get(s) + 1);
			} else {
				map.put(s, 1);
			}

		}

		System.out.println(result);
	}
}
