import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.List; List 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();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	} 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 List<String> inputList = new ArrayList<>(); inputList new ArrayList<>() for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		} {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		} char c[] = sc.nextLine().toCharArray(); c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc Arrays.sort(c) Arrays.sort Arrays c inputList.add(new String(c)) inputList.add inputList new String(c) Collections.sort(inputList) Collections.sort Collections inputList long result = 0; result 0 long cnt = 0; cnt 0 for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		} {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		} if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			} inputList.get(i).equals(inputList.get(i - 1)) inputList.get(i).equals inputList.get(i) inputList.get inputList i inputList.get(i - 1) inputList.get inputList i - 1 i 1 {
				cnt++;
			} cnt++ cnt {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			} result +=((cnt * (cnt + 1)) / 2) result ((cnt * (cnt + 1)) / 2) (cnt * (cnt + 1)) cnt (cnt + 1) cnt 1 2 cnt = 0 cnt 0 if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		} cnt >= 1 cnt 1 {
			result +=((cnt * (cnt + 1)) / 2);
		} result +=((cnt * (cnt + 1)) / 2) result ((cnt * (cnt + 1)) / 2) (cnt * (cnt + 1)) cnt (cnt + 1) cnt 1 2 System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
} public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		List<String> inputList = new ArrayList<>();

		for(int i = 0; i < n;i++) {
			char c[] = sc.nextLine().toCharArray();
			Arrays.sort(c);
			inputList.add(new String(c));
		}

		Collections.sort(inputList);
		long result = 0;

		long cnt = 0;
		for(int i = 1;i < n;i++) {
			if(inputList.get(i).equals(inputList.get(i - 1))) {
				cnt++;
			}else {
				result +=((cnt * (cnt + 1)) / 2);
				cnt = 0;
			}
		}

		if(cnt >= 1) {
			result +=((cnt * (cnt + 1)) / 2);
		}

		System.out.println(result);
	}
}
