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);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	}
} 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);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc char[] c = new char[10]; c new char[10] 10 String s; s HashMap<String, Long> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		} {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		} c = sc.next().toCharArray() c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c s = new String(c) s new String(c) if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			} map.get(s) == null map.get(s) map.get map s null {
				map.put(s, 1L);
			} map.put(s, 1L) map.put map s 1L {
				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 long ans = 0; ans 0 for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		} Long v map.values() map.values map {
			ans += v * (v - 1) / 2;
		} {
			ans += v * (v - 1) / 2;
		} ans += v * (v - 1) / 2 ans v * (v - 1) / 2 v * (v - 1) v (v - 1) v 1 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	}
} 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);
		int n = Integer.parseInt(sc.next());
		char[] c = new char[10];
		String s;
		HashMap<String, Long> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			Arrays.sort(c);
			s = new String(c);
			if (map.get(s) == null) {
				map.put(s, 1L);
			} else {
				map.put(s, map.get(s) + 1);
			}
		}

		long ans = 0;
		for (Long v : map.values()) {
			ans += v * (v - 1) / 2;
		}

		System.out.println(ans);
	}
}
