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();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/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);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long ans = 0; ans 0 HashMap<String,Long> sk = new HashMap<String,Long>(); sk new HashMap<String,Long>() for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		} {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		} String s = sc.next(); s sc.next() sc.next sc String[] po = s.split(""); po s.split("") s.split s "" Arrays.sort(po) Arrays.sort Arrays po s =String.join("",po) s String.join("",po) String.join String "" po if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			} sk.containsKey(s) sk.containsKey sk s {
				sk.put(s, sk.get(s)+1);
			} sk.put(s, sk.get(s)+1) sk.put sk s sk.get(s)+1 sk.get(s) sk.get sk s 1 {
				sk.put(s, 1l);
			} sk.put(s, 1l) sk.put sk s 1l for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		} long i sk.values() sk.values sk {
			ans+= (i-1)*(i)/2;
		} {
			ans+= (i-1)*(i)/2;
		} ans+= (i-1)*(i)/2 ans (i-1)*(i)/2 (i-1)*(i) (i-1) i 1 (i) 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);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/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);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	}
}