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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	}
} 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) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan HashMap<String, Long> map = new HashMap<>(); map new HashMap<>() int i; i String key; key char[] temp; temp for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		} i = 0; i = 0 i 0 i < n i n i++ i++ i {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		} {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		} key = scan.next() key scan.next() scan.next scan temp = key.toCharArray() temp key.toCharArray() key.toCharArray key Arrays.sort(temp) Arrays.sort Arrays temp key = new String(temp) key new String(temp) if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			} map.containsKey(key) map.containsKey map key {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			} long sum = map.get(key); sum map.get(key) map.get map key if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1); sum == 0 sum 0 map.put(key, new Long(1)) map.put map key new Long(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, new Long(0));
			} map.put(key, new Long(0)) map.put map key new Long(0) long ans = 0; ans 0 for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		} long a map.values() map.values map {
			ans += ((1 + a) * a) / 2;
		} {
			ans += ((1 + a) * a) / 2;
		} ans += ((1 + a) * a) / 2 ans ((1 + a) * a) / 2 ((1 + a) * a) (1 + a) 1 a a 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		HashMap<String, Long> map = new HashMap<>();
		int i;
		String key;
		char[] temp;

		for(i = 0; i < n; i++) {
			key = scan.next();
			temp = key.toCharArray();
			Arrays.sort(temp);
			key = new String(temp);

			if(map.containsKey(key)) {
				long sum = map.get(key);
				if(sum == 0)
					map.put(key, new Long(1));
				else
					map.put(key, map.get(key) + 1);
			}else {
				map.put(key, new Long(0));
			}
		}

		long ans = 0;
		for(long a: map.values()) {
			ans += ((1 + a) * a) / 2;
		}
		System.out.println(ans);
	}
}