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);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	}

} 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);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	}

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

	} main {
		Scanner sc = new Scanner(System.in);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) HashMap <String,Integer> hm = new HashMap<String,Integer>(); hm new HashMap<String,Integer>() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		} 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 = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		} {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		} 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 = String.valueOf(c); s String.valueOf(c) String.valueOf String c if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			} hm.containsKey(s) hm.containsKey hm s {
				hm.put(s, hm.get(s)+1);
			} hm.put(s, hm.get(s)+1) hm.put hm s hm.get(s)+1 hm.get(s) hm.get hm s 1 {
				hm.put(s,1);
			} hm.put(s,1) hm.put hm s 1 long ans = 0; ans 0 for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		} int a hm.values() hm.values hm {
			 ans += (long) a * (a -1) /2;
		} {
			 ans += (long) a * (a -1) /2;
		} ans += (long) a * (a -1) /2 ans (long) a * (a -1) /2 (long) a * (a -1) (long) a (a -1) a 1 2 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);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	}

} public class Main {

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

	}

} 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);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	}

}
