
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) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	}
}

 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) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-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 long ans =0; ans 0 Map<String,Long>strmap = new HashMap<String, Long>(); strmap new HashMap<String, Long>() for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		} {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		} char[] c = new char[10]; c new char[10] 10 c = sc.next().toCharArray() c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String let = String.valueOf(c); let String.valueOf(c) String.valueOf String c if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			} strmap.containsKey(let) strmap.containsKey strmap let {
				strmap.put(let, strmap.get(let) + 1);
			} strmap.put(let, strmap.get(let) + 1) strmap.put strmap let strmap.get(let) + 1 strmap.get(let) strmap.get strmap let 1 {
				strmap.put(let, 1L);
			} strmap.put(let, 1L) strmap.put strmap let 1L for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		} String string strmap.keySet() strmap.keySet strmap {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		} {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		} long dub = strmap.get(string); dub strmap.get(string) strmap.get strmap string ans += dub * (dub-1) / 2 ans dub * (dub-1) / 2 dub * (dub-1) dub (dub-1) dub 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();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-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();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	}
} 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) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans =0;

		Map<String,Long>strmap = new HashMap<String, Long>();

		for (int i = 0; i < N; i++) {
			char[] c = new char[10];
			c = sc.next().toCharArray();
			Arrays.sort(c);
			String let = String.valueOf(c);
			if (strmap.containsKey(let)) {
				strmap.put(let, strmap.get(let) + 1);
			} else {
				strmap.put(let, 1L);
			}
		}

		for (String string : strmap.keySet()) {
			long dub = strmap.get(string);
			ans += dub * (dub-1) / 2;
		}

		System.out.println(ans);

	}
}


