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,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	}
} 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,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		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 Map<String,Long> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		} {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		} char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String s = new String(c); s new String(c) if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			} !map.containsKey(s) map.containsKey(s) map.containsKey map s {
				map.put(s, (long)0);
			} map.put(s, (long)0) map.put map s (long)0 {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			} map.put(s, map.get(s)+1L) map.put map s map.get(s)+1L map.get(s) map.get map s 1L ans += map.get(s) ans map.get(s) map.get map s sc.close() sc.close sc 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 sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	}
} 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,Long> map = new HashMap<>();
		long ans = 0;
		for(int i = 0;i < N;i++) {
			char[] c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(!map.containsKey(s)) {
				map.put(s, (long)0);
			}else {
				map.put(s, map.get(s)+1L);
				ans += map.get(s);
			}
		}
		sc.close();
		System.out.println(ans);
	}
}