import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 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 Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		} {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		} char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(s) Arrays.sort Arrays s String ss = new String(s); ss new String(s) Integer cnt = map.get(ss); cnt map.get(ss) map.get map ss if (cnt == null) cnt = 0; cnt == null cnt null cnt = 0 cnt 0 map.put(ss, cnt + 1) map.put map ss cnt + 1 cnt 1 long ans = 0; ans 0 for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		} long x map.values() map.values map {
			ans += x * (x - 1) / 2;
		} {
			ans += x * (x - 1) / 2;
		} ans += x * (x - 1) / 2 ans x * (x - 1) / 2 x * (x - 1) x (x - 1) x 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 = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}
} Main
import java.util.*;

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