import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan scan.nextLine() scan.nextLine scan String[] array = new String[N]; array new String[N] N for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		} {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		} String s = scan.nextLine(); s scan.nextLine() scan.nextLine scan char[] chars = s.toCharArray(); chars s.toCharArray() s.toCharArray s Arrays.sort(chars) Arrays.sort Arrays chars array[i] = String.valueOf(chars) array[i] array i String.valueOf(chars) String.valueOf String chars Arrays.sort(array) Arrays.sort Arrays array String before = array[0]; before array[0] array 0 long cnt = 0; cnt 0 long addCnt = 0; addCnt 0 for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		} {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		} if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			} before.equals(array[i]) before.equals before array[i] array i {
				cnt += addCnt;
				addCnt++;
				cnt++;
			} cnt += addCnt cnt addCnt addCnt++ addCnt cnt++ cnt {
				addCnt = 0;
			} addCnt = 0 addCnt 0 before = array[i] before array[i] array i System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.nextLine();
		String[] array = new String[N];
		for (int i = 0; i < N; i++) {
			String s = scan.nextLine();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			array[i] = String.valueOf(chars);
		}
		Arrays.sort(array);
		String before = array[0];
		long cnt = 0;
		long addCnt = 0;
		for (int i = 1; i < N; i++) {
			if (before.equals(array[i])) {
				cnt += addCnt;
				addCnt++;
				cnt++;
			}
			else {
				addCnt = 0;
			}
			before = array[i];
		}

		System.out.println(cnt);
	}
}
