import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	}
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.util.Arrays; Arrays java.util import java.util.LinkedHashMap; LinkedHashMap java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	}
} Main public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	} main {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		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 LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>(); map new LinkedHashMap<String, Long>() for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		} {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		} String S = sort(sc.next()); S sort(sc.next()) sort sc.next() sc.next sc if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    } map.containsKey(S) map.containsKey map S {
		        map.put(S, map.get(S) + 1);
		    } map.put(S, map.get(S) + 1) map.put map S map.get(S) + 1 map.get(S) map.get map S 1 {
		        map.put(S, (long) 1);
		    } map.put(S, (long) 1) map.put map S (long) 1 long ans = 0; ans 0 for(Long i : map.values()) {
			ans += i*(i-1)/2;
		} Long i map.values() map.values map {
			ans += i*(i-1)/2;
		} {
			ans += i*(i-1)/2;
		} ans += i*(i-1)/2 ans i*(i-1)/2 i*(i-1) i (i-1) i 1 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	} sort {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	} char[] C = S.toCharArray(); C S.toCharArray() S.toCharArray S Arrays.sort(C) Arrays.sort Arrays C S = new String(C) S new String(C) return S; S String S S public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	}
} Main
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	}
}