import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String, Integer> hm = new HashMap<>(); hm new HashMap<>() char[] s; s Integer[] az; az String tmp; tmp for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		} {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		} s = sc.next().toCharArray() s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(s) Arrays.sort Arrays s tmp = "" tmp "" for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			} int j = 0; int j = 0; j 0 j < s.length j s.length s s.length j++ j++ j {
				tmp += s[j];
			} {
				tmp += s[j];
			} tmp += s[j] tmp s[j] s j if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			} hm.containsKey(tmp) hm.containsKey hm tmp {
				hm.put(tmp, hm.get(tmp) + 1);
			} hm.put(tmp, hm.get(tmp) + 1) hm.put hm tmp hm.get(tmp) + 1 hm.get(tmp) hm.get hm tmp 1 {
				hm.put(tmp, 1);
			} hm.put(tmp, 1) hm.put hm tmp 1 long sum = 0; sum 0 for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		} String str hm.keySet() hm.keySet hm {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		} {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		} sum += (long) hm.get(str) * (hm.get(str) - 1) / 2 sum (long) hm.get(str) * (hm.get(str) - 1) / 2 (long) hm.get(str) * (hm.get(str) - 1) (long) hm.get(str) hm.get hm str (hm.get(str) - 1) hm.get(str) hm.get hm str 1 2 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		HashMap<String, Integer> hm = new HashMap<>();
		char[] s;
		Integer[] az;
		String tmp;
		for (int i = 0; i < n; i++) {
			s = sc.next().toCharArray();
			Arrays.sort(s);
			tmp = "";
			for (int j = 0; j < s.length; j++) {
				tmp += s[j];
			}
			if (hm.containsKey(tmp)) {
				hm.put(tmp, hm.get(tmp) + 1);
			} else {
				hm.put(tmp, 1);
			}
		}
		long sum = 0;
		for (String str : hm.keySet()) {
			sum += (long) hm.get(str) * (hm.get(str) - 1) / 2;
		}
		System.out.println(sum);
	}
}
