import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	}

} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long co = 0; co 0 HashMap<String, Long> l = new HashMap<String, Long>(); l new HashMap<String, Long>() for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		} {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		} char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String S = new String(c); S new String(c) if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			} l.containsKey(S) l.containsKey l S {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} l.put(S, l.get(S) + 1) l.put l S l.get(S) + 1 l.get(S) l.get l S 1 co += l.get(S) co l.get(S) l.get l S {
				l.put(S, (long) 0);
			} l.put(S, (long) 0) l.put l S (long) 0 sc.close() sc.close sc System.out.println(co) System.out.println System.out System System.out co String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long co = 0;
		HashMap<String, Long> l = new HashMap<String, Long>();
		for (int i = 0; i < N; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String S = new String(c);
			if (l.containsKey(S)) {
				l.put(S, l.get(S) + 1);
				co += l.get(S);
			} else {
				l.put(S, (long) 0);
			}
		}
		sc.close();
		System.out.println(co);
	}

}