import java.util.*;

public class Main {
	Scanner sc;
	Map<String, Integer> h;
	int N;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

} import java.util.*; util.* java public class Main {
	Scanner sc;
	Map<String, Integer> h;
	int N;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

} Main Scanner sc; sc Map<String, Integer> h; h int N; N public Main() {
		sc = new Scanner(System.in);
	} Main {
		sc = new Scanner(System.in);
	} sc = new Scanner(System.in) sc new Scanner(System.in) private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	} calc {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	} N = sc.nextInt() N sc.nextInt() sc.nextInt sc h = new HashMap<>() h new HashMap<>() for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		} {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		} char[] cs = sc.next().toCharArray(); cs sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(cs) Arrays.sort Arrays cs String s = new String(cs); s new String(cs) h.put(s, h.getOrDefault(s, 0)+1) h.put h s h.getOrDefault(s, 0)+1 h.getOrDefault(s, 0) h.getOrDefault h s 0 1 long result = 0L; result 0L for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		} String s h.keySet() h.keySet h {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		} {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		} int cnt = h.get(s); cnt h.get(s) h.get h s if (cnt <= 1) continue; cnt <= 1 cnt 1 continue; result = result + ((long)cnt)*(cnt-1)/2 result result + ((long)cnt)*(cnt-1)/2 result ((long)cnt)*(cnt-1)/2 ((long)cnt)*(cnt-1) ((long)cnt) (cnt-1) cnt 1 2 out(result) out result private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	} out {
		System.out.println(o);
		System.out.flush();
	} System.out.println(o) System.out.println System.out System System.out o System.out.flush() System.out.flush System.out System System.out Object o o public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	} main {
		Main m = new Main();
		m.calc();
	} Main m = new Main(); m new Main() m.calc() m.calc m String[] args args public class Main {
	Scanner sc;
	Map<String, Integer> h;
	int N;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

} public class Main {
	Scanner sc;
	Map<String, Integer> h;
	int N;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

} Main
import java.util.*;

public class Main {
	Scanner sc;
	Map<String, Integer> h;
	int N;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		h = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] cs = sc.next().toCharArray();
			Arrays.sort(cs);
			String s = new String(cs);
			h.put(s, h.getOrDefault(s, 0)+1);
		}
		long result = 0L;
		for (String s : h.keySet()) {
			int cnt = h.get(s);
			if (cnt <= 1) continue;
			result = result + ((long)cnt)*(cnt-1)/2;
		}
		out(result);
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}