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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	}

	public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	}
} 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) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	}

	public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc HashMap<String, Long>map = new HashMap<String, Long>(); map new HashMap<String, Long>() for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		} {
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		} String input = sc.next(); input sc.next() sc.next sc char[] charInput = input.toCharArray(); charInput input.toCharArray() input.toCharArray input String sorted; sorted Arrays.sort(charInput) Arrays.sort Arrays charInput sorted = String.valueOf(charInput) sorted String.valueOf(charInput) String.valueOf String charInput if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			} map.containsKey(sorted) map.containsKey map sorted {
				map.put(sorted, map.get(sorted)+1);
			} map.put(sorted, map.get(sorted)+1) map.put map sorted map.get(sorted)+1 map.get(sorted) map.get map sorted 1 {
				map.put(sorted, 1L);
			} map.put(sorted, 1L) map.put map sorted 1L long ans = 0; ans 0 for (long cnt : map.values()){
			ans += combination(cnt);
		} long cnt map.values() map.values map {
			ans += combination(cnt);
		} {
			ans += combination(cnt);
		} ans += combination(cnt) ans combination(cnt) combination cnt System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	} combination {
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	} long ret = 0; ret 0 for (long i=1; i<=cnt-1; i++){
			ret += i;
		} long i=1; long i=1; i 1 i<=cnt-1 i cnt-1 cnt 1 i++ i++ i {
			ret += i;
		} {
			ret += i;
		} ret += i ret i return ret; ret long cnt cnt public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	}

	public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	}

	public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashMap<String, Long>map = new HashMap<String, Long>();

		for (int i=0; i<N; i++){
			String input = sc.next();
			char[] charInput = input.toCharArray();
			String sorted;
			Arrays.sort(charInput);
			sorted = String.valueOf(charInput);
			if (map.containsKey(sorted)){
				map.put(sorted, map.get(sorted)+1);
			} else {
				map.put(sorted, 1L);
			}
		}
		long ans = 0;
		for (long cnt : map.values()){
			ans += combination(cnt);
		}
		System.out.println(ans);
	}

	public static long combination(long cnt){
		long ret = 0;
		for (long i=1; i<=cnt-1; i++){
			ret += i;
		}
		return ret;
	}
}