import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	}
	
	public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	}

} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet 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.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	}
	
	public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	}

} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	} main {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc HashMap<String, Integer> strMap = new HashMap<>(); strMap new HashMap<>() HashSet<String> strSet = new HashSet<>(); strSet new HashSet<>() long valiation = 0; valiation 0 for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		} {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		} String[] strArr = sc.nextLine().split(""); strArr sc.nextLine().split("") sc.nextLine().split sc.nextLine() sc.nextLine sc "" Arrays.sort(strArr) Arrays.sort Arrays strArr String concatStr = ""; concatStr "" for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			} int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
				concatStr = concatStr.concat(strArr[j]);
			} {
				concatStr = concatStr.concat(strArr[j]);
			} concatStr = concatStr.concat(strArr[j]) concatStr concatStr.concat(strArr[j]) concatStr.concat concatStr strArr[j] strArr j if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			} strMap.containsKey(concatStr) strMap.containsKey strMap concatStr {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			} valiation += strMap.get(concatStr) valiation strMap.get(concatStr) strMap.get strMap concatStr strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1) strMap.put strMap concatStr new Integer(strMap.get(concatStr)) + 1 new Integer(strMap.get(concatStr)) 1 {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			} strMap.put(concatStr, new Integer(1)) strMap.put strMap concatStr new Integer(1) strSet.add(concatStr) strSet.add strSet concatStr sc.close() sc.close sc System.out.println(valiation) System.out.println System.out System System.out valiation String[] args args public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	} factorial {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	} long result = 1; result 1 for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		} int i = 1 ; int i = 1 ; i 1 i <= n i n i++ i++ i {
			result *= (long)i;
		} {
			result *= (long)i;
		} result *= (long)i result (long)i return result; result int n n public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	}
	
	public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	}

} public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	}
	
	public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	}

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

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		HashMap<String, Integer> strMap = new HashMap<>();
		HashSet<String> strSet = new HashSet<>();
		long valiation = 0;
		for(int i = 0; i < n; i++) {
			String[] strArr = sc.nextLine().split("");
			Arrays.sort(strArr);
			String concatStr = "";
			for(int j = 0; j < 10; j++) {
				concatStr = concatStr.concat(strArr[j]);
			}
			if(strMap.containsKey(concatStr)) {
				valiation += strMap.get(concatStr);
				strMap.put(concatStr, new Integer(strMap.get(concatStr)) + 1);
			}else {
				strMap.put(concatStr, new Integer(1));
				strSet.add(concatStr);
			}
		}
		sc.close();		
		
		System.out.println(valiation);
	}
	
	public static long factorial(int n) {
		long result = 1;
		for(int i = 1 ; i <= n; i++) {
			result *= (long)i;
		}
		return result;
	}

}
