import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	} main {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long re =0; re 0 Map<String,Long>  map = new HashMap<String,Long> (); map new HashMap<String,Long> () int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		} {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		} String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.parallelSort(c) Arrays.parallelSort Arrays c String temp = String.valueOf(c); temp String.valueOf(c) String.valueOf String c if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			} map.containsKey(temp)==false map.containsKey(temp) map.containsKey map temp false {
				map.put(temp, 1l);
			} map.put(temp, 1l) map.put map temp 1l {
				Long in = map.get(temp);
				map.put(temp, in+1);
			} Long in = map.get(temp); in map.get(temp) map.get map temp map.put(temp, in+1) map.put map temp in+1 in 1 Set<String> set = map.keySet(); set map.keySet() map.keySet map for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		} String s set {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		} {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		} Long in = map.get(s); in map.get(s) map.get map s if (in>1) {
				re +=(in)*(in-1)/2;
			} in>1 in 1 {
				re +=(in)*(in-1)/2;
			} re +=(in)*(in-1)/2 re (in)*(in-1)/2 (in)*(in-1) (in) (in-1) in 1 2 System.out.println(re) System.out.println System.out System System.out re String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long re =0;
		Map<String,Long>  map = new HashMap<String,Long> ();
		int N = sc.nextInt();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			char[] c = s.toCharArray();
			Arrays.parallelSort(c);
			String temp = String.valueOf(c);
			if (map.containsKey(temp)==false) {
				map.put(temp, 1l);
			} else {
				Long in = map.get(temp);
				map.put(temp, in+1);
			}
		}
		Set<String> set = map.keySet();
		for (String s: set) {
			Long in = map.get(s);
			if (in>1) {
				re +=(in)*(in-1)/2;
			}
		}
		System.out.println(re);
	}
}