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;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			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;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int N;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int N;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		} {
			int N;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int N; N N = Integer.parseInt(scanner.nextLine()) N Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner Map<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() long ans = 0; ans 0 for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			} {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			} char[] tmp = scanner.nextLine().toCharArray(); tmp scanner.nextLine().toCharArray() scanner.nextLine().toCharArray scanner.nextLine() scanner.nextLine scanner Arrays.sort(tmp) Arrays.sort Arrays tmp String key = new String(tmp); key new String(tmp) if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				} map.containsKey(key) map.containsKey map key {
					map.put(key, map.get(key) + 1L);
				} map.put(key, map.get(key) + 1L) map.put map key map.get(key) + 1L map.get(key) map.get map key 1L {
					map.put(key, 1L);
				} map.put(key, 1L) map.put map key 1L for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			} long l map.values() map.values map {
				ans += (l * (l - 1L)) / 2L;
			} {
				ans += (l * (l - 1L)) / 2L;
			} ans += (l * (l - 1L)) / 2L ans (l * (l - 1L)) / 2L (l * (l - 1L)) l (l - 1L) l 1L 2L 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;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			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;
			N = Integer.parseInt(scanner.nextLine());
			Map<String, Long> map = new HashMap<String, Long>();

			long ans = 0;
			for (int i = 0; i < N; i++) {
				char[] tmp = scanner.nextLine().toCharArray();
				Arrays.sort(tmp);

				String key = new String(tmp);
				if (map.containsKey(key)) {
					map.put(key, map.get(key) + 1L);
				} else {
					map.put(key, 1L);
				}
			}
			for (long l : map.values()) {
				ans += (l * (l - 1L)) / 2L;
			}
			System.out.println(ans);
		}
	}
}