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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map 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();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Map<String, Integer> S = new HashMap<>(); S new HashMap<>() long r = 0L; r 0L for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		} {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		} char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(s) Arrays.sort Arrays s String ss = String.valueOf(s); ss String.valueOf(s) String.valueOf String s int cnt = 0; cnt 0 if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			} S.containsKey(ss) S.containsKey S ss {
				cnt = S.get(ss);
				r += cnt;
			} cnt = S.get(ss) cnt S.get(ss) S.get S ss r += cnt r cnt S.put(ss, ++cnt) S.put S ss ++cnt cnt sc.close() sc.close sc System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
}