
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 sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	}

	private static long calc(long num) {
		return (num * (num - 1)) / 2;
	}

	private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} 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 sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	}

	private static long calc(long num) {
		return (num * (num - 1)) / 2;
	}

	private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		} {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Map<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			} {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			} String tmp = change(sc.next()); tmp change(sc.next()) change sc.next() sc.next sc if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				} map.containsKey(tmp) map.containsKey map tmp {
					map.put(tmp, map.get(tmp)+1);
				} 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, 1);
				} map.put(tmp, 1) map.put map tmp 1 long result = 0; result 0 for (String str : map.keySet()) {
				result += calc(map.get(str));
			} String str map.keySet() map.keySet map {
				result += calc(map.get(str));
			} {
				result += calc(map.get(str));
			} result += calc(map.get(str)) result calc(map.get(str)) calc map.get(str) map.get map str System.out.println(result) System.out.println System.out System System.out result String[] args args private static long calc(long num) {
		return (num * (num - 1)) / 2;
	} calc {
		return (num * (num - 1)) / 2;
	} return (num * (num - 1)) / 2; (num * (num - 1)) / 2 (num * (num - 1)) num (num - 1) num 1 2 long num num private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	} change {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	} char[] arr = str.toCharArray(); arr str.toCharArray() str.toCharArray str Arrays.sort(arr) Arrays.sort Arrays arr return new String(arr); new String(arr) String str str public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	}

	private static long calc(long num) {
		return (num * (num - 1)) / 2;
	}

	private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	}

	private static long calc(long num) {
		return (num * (num - 1)) / 2;
	}

	private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} 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 sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<String, Integer>();
			for (int i = 0; i < n; i++) {
				String tmp = change(sc.next());
				if (map.containsKey(tmp)) {
					map.put(tmp, map.get(tmp)+1);
				} else {
					map.put(tmp, 1);
				}
			}
			long result = 0;

			for (String str : map.keySet()) {
				result += calc(map.get(str));
			}
			System.out.println(result);
		}
	}

	private static long calc(long num) {
		return (num * (num - 1)) / 2;
	}

	private static String change(String str) {
		char[] arr = str.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
}
