import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		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();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		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 sc.nextLine() sc.nextLine sc String[] arr = new String[n+1]; arr new String[n+1] n+1 n 1 for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		} {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		} arr[i] = sc.nextLine() arr[i] arr i sc.nextLine() sc.nextLine sc char temparr[] = arr[i].toCharArray(); temparr arr[i].toCharArray() arr[i].toCharArray arr[i] arr i Arrays.sort(temparr) Arrays.sort Arrays temparr arr[i] = new String(temparr) arr[i] arr i new String(temparr) arr[n] = "zzzzzzzzzzzzz" arr[n] arr n "zzzzzzzzzzzzz" Arrays.sort(arr) Arrays.sort Arrays arr long ans = 0; ans 0 long freq = 1; freq 1 for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		} {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		} if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				} arr[i].equals(arr[i + 1]) arr[i].equals arr[i] arr i arr[i + 1] arr i + 1 i 1 {
//					System.out.println("cnt");
					freq += 1;
				} freq += 1 freq 1 if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				} freq == 1 freq 1 {
					continue;
				} continue; {
					ans += freq*(freq - 1)/2;
					freq = 1;
				} ans += freq*(freq - 1)/2 ans freq*(freq - 1)/2 freq*(freq - 1) freq (freq - 1) freq 1 2 freq = 1 freq 1 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();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		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();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		System.out.println(ans);
	}
}