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();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	}

} 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();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	}

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] s = new String[n]; s new String[n] n for (int i=0; i<n; i++) {
			s[i] = sc.next();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			s[i] = sc.next();
		} {
			s[i] = sc.next();
		} s[i] = sc.next() s[i] s i sc.next() sc.next sc sc.close() sc.close sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		} int i=0; int i=0; i 0 i<s.length i s.length s s.length i++ i++ i {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		} {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		} char[] c = s[i].toCharArray(); c s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(c) Arrays.sort Arrays c String key = String.valueOf(c); key String.valueOf(c) String.valueOf String c if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			} map.containsKey(key) map.containsKey map key {
				map.put(key, map.get(key) + 1);
			} map.put(key, map.get(key) + 1) map.put map key map.get(key) + 1 map.get(key) map.get map key 1 {
				map.put(key, 1);
			} map.put(key, 1) map.put map key 1 long cnt = 0; cnt 0 for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		} Integer v map.values() map.values map {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		} {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		} if (v == 1) continue; v == 1 v 1 continue; long t = (long)v; t (long)v cnt += (t*t - t) / 2 cnt (t*t - t) / 2 (t*t - t) t*t t t t 2 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	}

} 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();
		String[] s = new String[n];
		for (int i=0; i<n; i++) {
			s[i] = sc.next();
		}
		sc.close();

		Map<String, Integer> map = new HashMap<>();
		for (int i=0; i<s.length; i++) {
			char[] c = s[i].toCharArray();
			Arrays.sort(c);
			String key = String.valueOf(c);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long cnt = 0;
		for (Integer v : map.values()) {
			if (v == 1) continue;
			long t = (long)v;
			cnt += (t*t - t) / 2;
		}

		System.out.println(cnt);
	}

}