import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		}
} 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 sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc String[] a = new String[N]; a new String[N] N long sum= 0; sum 0 HashMap<String,Long> map = new HashMap<String,Long>(); map new HashMap<String,Long>() for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		} int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		} {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		} a[i]=sc.next() a[i] a i sc.next() sc.next sc char []chars =a[i].toCharArray(); chars a[i].toCharArray() a[i].toCharArray a[i] a i Arrays.sort(chars) Arrays.sort Arrays chars String sorted = new String(chars); sorted new String(chars) if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			} map.containsKey(sorted) map.containsKey map sorted {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			} sum+=map.get(sorted) sum map.get(sorted) map.get map sorted map.put(sorted, map.get(sorted)+1) map.put map sorted map.get(sorted)+1 map.get(sorted) map.get map sorted 1 {
				map.put(sorted,1L);
			} map.put(sorted,1L) map.put map sorted 1L System.out.print(sum) System.out.print System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] a = new String[N];
		long sum= 0;
		HashMap<String,Long> map = new HashMap<String,Long>();
		for(int i = 0;i<N;i++) {
			a[i]=sc.next();
	        char []chars =a[i].toCharArray();
	        Arrays.sort(chars);
	        String sorted = new String(chars);

			if(map.containsKey(sorted)) {;
				sum+=map.get(sorted);
				map.put(sorted, map.get(sorted)+1);
			}
			else {
				map.put(sorted,1L);
			}
		}
		System.out.print(sum);
		}
}
