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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	}
} 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	} main {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan String[] stringList = new String[n]; stringList new String[n] n for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			stringList[i] = scan.next();
		} {
			stringList[i] = scan.next();
		} stringList[i] = scan.next() stringList[i] stringList i scan.next() scan.next scan long count = 0; count 0 Map<String, Long> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		} {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		} char[] c = stringList[i].toCharArray(); c stringList[i].toCharArray() stringList[i].toCharArray stringList[i] stringList i Arrays.sort(c) Arrays.sort Arrays c String str = String.valueOf(c); str String.valueOf(c) String.valueOf String c if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			} map.containsKey(str) map.containsKey map str {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} long num = map.get(str); num map.get(str) map.get map str count += num count num map.put(str, num + 1) map.put map str num + 1 num 1 {
				map.put(str, 1l);
			} map.put(str, 1l) map.put map str 1l System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	}
} 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] stringList = new String[n];
		for (int i = 0; i < n; i++) {
			stringList[i] = scan.next();
		}

		long count = 0;

		Map<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {

			char[] c = stringList[i].toCharArray();
			Arrays.sort(c);
			String str = String.valueOf(c);
			if (map.containsKey(str)) {
				long num = map.get(str);
				count += num;
				map.put(str, num + 1);
			} else {
				map.put(str, 1l);
			}


		}

		System.out.println(count);
	}
}