import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
 class Main {
		public static void main(String[]args) {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		}
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util class Main {
		public static void main(String[]args) {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		}
} Main public static void main(String[]args) {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		} main {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan HashMap<String,Integer> hmap = new HashMap<>(); hmap new HashMap<>() for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			} int i = 0 ; int i = 0 ; i 0 i< n i n i++ i++ i {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			} {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			} char[] c = scan.next().toCharArray(); c scan.next().toCharArray() scan.next().toCharArray scan.next() scan.next scan Arrays.sort(c) Arrays.sort Arrays c String s = String.valueOf(c); s String.valueOf(c) String.valueOf String c if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				} hmap.containsKey(s) hmap.containsKey hmap s {
					hmap.put(s, hmap.get(s)+1);
				} hmap.put(s, hmap.get(s)+1) hmap.put hmap s hmap.get(s)+1 hmap.get(s) hmap.get hmap s 1 {
					hmap.put(s,1);
				} hmap.put(s,1) hmap.put hmap s 1 long count = 0 ; count 0 for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			} int a hmap.values() hmap.values hmap {
				count += (long)a*(a-1)/2 ;
			} {
				count += (long)a*(a-1)/2 ;
			} count += (long)a*(a-1)/2 count (long)a*(a-1)/2 (long)a*(a-1) (long)a (a-1) a 1 2 System.out.println(count) System.out.println System.out System System.out count String[]args args
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
 class Main {
		public static void main(String[]args) {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		}
}