import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc Map<String, Long> s = new HashMap<>(); s new HashMap<>() for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		} {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		} char[] cs = sc.nextLine().toCharArray(); cs sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc Arrays.sort(cs) Arrays.sort Arrays cs String string = new String(cs); string new String(cs) s.put(string, s.getOrDefault(string, 0L) + 1L) s.put s string s.getOrDefault(string, 0L) + 1L s.getOrDefault(string, 0L) s.getOrDefault s string 0L 1L long answer = 0; answer 0 for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		} String k s.keySet() s.keySet s {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		} {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		} answer += s.get(k) * (s.get(k) - 1) / 2 answer s.get(k) * (s.get(k) - 1) / 2 s.get(k) * (s.get(k) - 1) s.get(k) s.get s k (s.get(k) - 1) s.get(k) s.get s k 1 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		Map<String, Long> s = new HashMap<>();
		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			String string = new String(cs);
			s.put(string, s.getOrDefault(string, 0L) + 1L);
		}

		long answer = 0;
		for (String k : s.keySet()) {
			answer += s.get(k) * (s.get(k) - 1) / 2;
		}
		System.out.println(answer);
	}
}
