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) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	}
} 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) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		} {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner long ans = 0; ans 0 Map<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			} {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			} char[] array = scanner.next().toCharArray(); array scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner Arrays.sort(array) Arrays.sort Arrays array String tmp = new String(array); tmp new String(array) if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				} map.containsKey(tmp) map.containsKey map tmp {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} ans = ans + map.get(tmp) ans ans + map.get(tmp) ans map.get(tmp) map.get map tmp map.put(tmp, map.get(tmp) + 1) map.put map tmp map.get(tmp) + 1 map.get(tmp) map.get map tmp 1 {
					map.put(tmp, (long) 1);
				} map.put(tmp, (long) 1) map.put map tmp (long) 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	}
} 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) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			long ans = 0;
			Map<String, Long> map = new HashMap<String, Long>();
			for (int i = 0; i < N; i++) {
				char[] array = scanner.next().toCharArray();
				Arrays.sort(array);
				String tmp = new String(array);
				if (map.containsKey(tmp)) {
					ans = ans + map.get(tmp);
					map.put(tmp, map.get(tmp) + 1);
				} else {
					map.put(tmp, (long) 1);
				}
			}
			System.out.println(ans);
		}
	}
}
