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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

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

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			s[i] = String.valueOf(c);
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, s[i]);
		}

		long ans = 0;
		for (long val : map.values()) {
			ans += val * (val - 1) / 2;
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}
