import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	}
} Main public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		} {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		} char[] arr = sc.next().toCharArray(); arr sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(arr) Arrays.sort Arrays arr String s = new String(arr); s new String(arr) if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    } map.containsKey(s) map.containsKey map s {
		        map.put(s, map.get(s) + 1);
		    } map.put(s, map.get(s) + 1) map.put map s map.get(s) + 1 map.get(s) map.get map s 1 {
		        map.put(s, 1);
		    } map.put(s, 1) map.put map s 1 long total = 0; total 0 for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		} int x map.values() map.values map {
		    total += (long) x * (x - 1) / 2;
		} {
		    total += (long) x * (x - 1) / 2;
		} total += (long) x * (x - 1) / 2 total (long) x * (x - 1) / 2 (long) x * (x - 1) (long) x (x - 1) x 1 2 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	}
} public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	}
} Main
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    char[] arr = sc.next().toCharArray();
		    Arrays.sort(arr);
		    String s = new String(arr);
		    if (map.containsKey(s)) {
		        map.put(s, map.get(s) + 1);
		    } else {
		        map.put(s, 1);
		    }
		}
		long total = 0;
		for (int x : map.values()) {
		    total += (long) x * (x - 1) / 2;
		}
		System.out.println(total);
	}
}
