import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List 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();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc String[] ss = new String[n]; ss new String[n] n for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		} {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		} char[] cs = sc.nextLine().toCharArray(); cs sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc Arrays.sort(cs) Arrays.sort Arrays cs ss[i] = new String(cs) ss[i] ss i new String(cs) Arrays.sort(ss) Arrays.sort Arrays ss List<Long> same = new ArrayList<>(); same new ArrayList<>() for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		} {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		} long count = 1; count 1 while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			} i < n && ss[i].equals(ss[i - 1]) i < n i n ss[i].equals(ss[i - 1]) ss[i].equals ss[i] ss i ss[i - 1] ss i - 1 i 1 {
				i++;
				count++;
			} i++ i count++ count if (count > 1) same.add(count); count > 1 count 1 same.add(count) same.add same count long answer = 0; answer 0 for (Long m : same) answer += m * (m - 1) / 2; Long m same answer += m * (m - 1) / 2; answer += m * (m - 1) / 2 answer m * (m - 1) / 2 m * (m - 1) m (m - 1) m 1 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();

		String[] ss = new String[n];

		for (int i = 0; i < n; i++) {
			char[] cs = sc.nextLine().toCharArray();
			Arrays.sort(cs);
			ss[i] = new String(cs);
		}

		Arrays.sort(ss);
		List<Long> same = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			long count = 1;
			while (i < n && ss[i].equals(ss[i - 1])) {
				i++;
				count++;
			}
			if (count > 1) same.add(count);
		}
		long answer = 0;
		for (Long m : same) answer += m * (m - 1) / 2;
		System.out.println(answer);
	}
}
