import java.util.*;
import static java.lang.Integer.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	}
} import java.util.*; util.* java import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) int n = parseInt(sc.next()); n parseInt(sc.next()) parseInt sc.next() sc.next sc String[] s = new String[n]; s new String[n] n for(i=0;i<n;i++) {
			s[i] = sc.next();
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			s[i] = sc.next();
		} {
			s[i] = sc.next();
		} s[i] = sc.next() s[i] s i sc.next() sc.next sc sc.close() sc.close sc String[] s2; s2 for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		} {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		} s2 = s[i].split("") s2 s[i].split("") s[i].split s[i] s i "" Arrays.sort(s2) Arrays.sort Arrays s2 s[i] = String.join("", s2) s[i] s i String.join("", s2) String.join String "" s2 HashMap<String, Integer> c = new  HashMap<>(); c new  HashMap<>() for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		} i=0; i=0 i 0 i<n i n i++ i++ i {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		} {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		} if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			} c.containsKey(s[i]) c.containsKey c s[i] s i {
				c.put(s[i], c.get(s[i])+1);
			} c.put(s[i], c.get(s[i])+1) c.put c s[i] s i c.get(s[i])+1 c.get(s[i]) c.get c s[i] s i 1 {
				c.put(s[i], 1);
			} c.put(s[i], 1) c.put c s[i] s i 1 long ans=0; ans 0 for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		} Integer ii c.values() c.values c {
			ans += (long)ii*(ii-1)/2;
		} {
			ans += (long)ii*(ii-1)/2;
		} ans += (long)ii*(ii-1)/2 ans (long)ii*(ii-1)/2 (long)ii*(ii-1) (long)ii (ii-1) ii 1 2 out.println(ans) out.println out ans String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	}
} Main
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String[] s = new String[n];
		for(i=0;i<n;i++) {
			s[i] = sc.next();
		}
		sc.close();
		String[] s2;
		for(i=0;i<n;i++) {
			s2 = s[i].split("");
			Arrays.sort(s2);
			s[i] = String.join("", s2);
		}
		HashMap<String, Integer> c = new  HashMap<>();
		for(i=0;i<n;i++) {
			if(c.containsKey(s[i])) {
				c.put(s[i], c.get(s[i])+1);
			} else {
				c.put(s[i], 1);
			}
		}
		long ans=0;
		for (Integer ii : c.values()) {
			ans += (long)ii*(ii-1)/2;
		}
		out.println(ans);
	}
}
