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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	}

} import java.util.Arrays; Arrays 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 = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long count = 0; count 0 long subcount = 1; subcount 1 String[] S = new String[n]; S new String[n] n String s = "0"; s "0" String[] s2 = new String[10]; s2 new String[10] 10 for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		} {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		} s = sc.next() s sc.next() sc.next sc for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1); int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j s2[j] = s.substring(j,j+1); s2[j] = s.substring(j,j+1) s2[j] s2 j s.substring(j,j+1) s.substring s j j+1 j 1 Arrays.sort(s2) Arrays.sort Arrays s2 S[i] = Arrays.toString(s2) S[i] S i Arrays.toString(s2) Arrays.toString Arrays s2 Arrays.sort(S) Arrays.sort Arrays S for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		} int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		} {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		} if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			} S[i].equals(S[i+1]) S[i].equals S[i] S i S[i+1] S i+1 i 1 {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} subcount++ subcount if(i == n-2) count += subcount*(subcount-1)/2; i == n-2 i n-2 n 2 count += subcount*(subcount-1)/2 count subcount*(subcount-1)/2 subcount*(subcount-1) subcount (subcount-1) subcount 1 2 {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			} count += subcount*(subcount-1)/2 count subcount*(subcount-1)/2 subcount*(subcount-1) subcount (subcount-1) subcount 1 2 subcount = 1 subcount 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long count = 0; long subcount = 1;
		String[] S = new String[n];
		String s = "0"; String[] s2 = new String[10];
 		for(int i = 0; i < n; i++) {
			s = sc.next();
			for(int j = 0; j < 10; j++)
				s2[j] = s.substring(j,j+1);
		Arrays.sort(s2);
		S[i] = Arrays.toString(s2);
		}
 		Arrays.sort(S);
 		for(int i = 0; i < n-1; i++) {
 			if(S[i].equals(S[i+1])) {
 				subcount++;
 				if(i == n-2) count += subcount*(subcount-1)/2;
 			} else {
 				count += subcount*(subcount-1)/2;
 				subcount = 1;
 			}
 		}
 		System.out.println(count);
	}

}