import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	}
		
		
	} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	}
		
		
	} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc HashMap<String,Integer> hm = new HashMap<>(); hm new HashMap<>() for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		} {
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		} String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc char[] chr = s.toCharArray(); chr s.toCharArray() s.toCharArray s Arrays.sort(chr) Arrays.sort Arrays chr String str = String.valueOf(chr); str String.valueOf(chr) String.valueOf String chr hm.put(str, 1 + hm.getOrDefault(str,0)) hm.put hm str 1 + hm.getOrDefault(str,0) 1 hm.getOrDefault(str,0) hm.getOrDefault hm str 0 long count = 0; count 0 for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		} long cur hm.values() hm.values hm {
			count += (cur * (cur - 1)/2);
		} {
			count += (cur * (cur - 1)/2);
		} count += (cur * (cur - 1)/2) count (cur * (cur - 1)/2) cur * (cur - 1) cur (cur - 1) cur 1 2 System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	}
		
		
	}