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