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

public class Main {
	public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	}


} 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) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	}


} Main public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	} main {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	} int a; a Scanner sc = new Scanner(System.in); sc new Scanner(System.in) a = sc.nextInt() a sc.nextInt() sc.nextInt sc String[] ArrayA = new String[a]; ArrayA new String[a] a HashMap<String, Integer> hm = new HashMap<>(); hm new HashMap<>() for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		} int i = 0; int i = 0; i 0 i < ArrayA.length i ArrayA.length ArrayA ArrayA.length i++ i++ i {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		} {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		} String b = sc.next(); b sc.next() sc.next sc char[] c = b.toCharArray(); c b.toCharArray() b.toCharArray b Arrays.sort(c) Arrays.sort Arrays c hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1) hm.put hm String.valueOf(c) String.valueOf String c hm.getOrDefault(String.valueOf(c), 0) + 1 hm.getOrDefault(String.valueOf(c), 0) hm.getOrDefault hm String.valueOf(c) String.valueOf String c 0 1 long ans = 0; ans 0 for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		} String s hm.keySet() hm.keySet hm {
			ans += nc2(hm.get(s));
		} {
			ans += nc2(hm.get(s));
		} ans += nc2(hm.get(s)) ans nc2(hm.get(s)) nc2 hm.get(s) hm.get hm s System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	} nc2 {
		return (x * (x - 1)) / 2;
	} return (x * (x - 1)) / 2; (x * (x - 1)) / 2 (x * (x - 1)) x (x - 1) x 1 2 long x x public class Main {
	public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	}


} public class Main {
	public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	}


} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();

		String[] ArrayA = new String[a];
		HashMap<String, Integer> hm = new HashMap<>();

		for(int i = 0; i < ArrayA.length; i++) {
			String b = sc.next();
			char[] c = b.toCharArray();
			Arrays.sort(c);
			hm.put(String.valueOf(c), hm.getOrDefault(String.valueOf(c), 0) + 1);
		}

		long ans = 0;
		for (String s : hm.keySet()) {
			ans += nc2(hm.get(s));
		}

		System.out.println(ans);
	}

	private static long nc2(long x) {
		return (x * (x - 1)) / 2;
	}


}
