import java.security.KeyStore.Entry;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
} import java.security.KeyStore.Entry; Entry java.security.KeyStore import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
} Main public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	} run {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) HashMap<Long, Long> map = new HashMap<>(); map new HashMap<>() int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		} int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		} {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		} char[] cs = sc.next().toCharArray(); cs sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int[] a = new int[cs.length]; a new int[cs.length] cs.length cs cs.length for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a'; int j = 0; int j = 0; j 0 j < a.length j a.length a a.length ++j ++j j a[j] = cs[j] - 'a'; a[j] = cs[j] - 'a' a[j] a j cs[j] - 'a' cs[j] cs j 'a' Arrays.sort(a) Arrays.sort Arrays a long add = 0; add 0 for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			} int j = 0; int j = 0; j 0 j < a.length j a.length a a.length ++j ++j j {
				add = add * 26 + a[j];
			} {
				add = add * 26 + a[j];
			} add = add * 26 + a[j] add add * 26 + a[j] add * 26 add 26 a[j] a j if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			} map.containsKey(add) map.containsKey map add {
				map.put(add, map.get(add) + 1);
			} map.put(add, map.get(add) + 1) map.put map add map.get(add) + 1 map.get(add) map.get map add 1 {
				map.put(add, (long) 1);
			} map.put(add, (long) 1) map.put map add (long) 1 long ans = 0; ans 0 for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		} java.util.Map.Entry<Long, Long> entry map.entrySet() map.entrySet map {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		} {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		} long v = entry.getValue(); v entry.getValue() entry.getValue entry ans += v * (v - 1) / 2 ans v * (v - 1) / 2 v * (v - 1) v (v - 1) v 1 2 System.out.println(ans) System.out.println System.out System System.out ans static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	} tr {
		System.out.println(Arrays.deepToString(objects));
	} System.out.println(Arrays.deepToString(objects)) System.out.println System.out System System.out Arrays.deepToString(objects) Arrays.deepToString Arrays objects Object... objects objects public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
} public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
} Main
import java.security.KeyStore.Entry;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		HashMap<Long, Long> map = new HashMap<>();
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char[] cs = sc.next().toCharArray();
			int[] a = new int[cs.length];
			for (int j = 0; j < a.length; ++j)
				a[j] = cs[j] - 'a';
			Arrays.sort(a);
			long add = 0;
			for (int j = 0; j < a.length; ++j) {
				add = add * 26 + a[j];
			}
			if (map.containsKey(add)) {
				map.put(add, map.get(add) + 1);
			} else {
				map.put(add, (long) 1);
			}
		}
		long ans = 0;
		for (java.util.Map.Entry<Long, Long> entry : map.entrySet()) {
			long v = entry.getValue();
			ans += v * (v - 1) / 2;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
