import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   }
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   }
} Main public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   } main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] arr = new String[n]; arr new String[n] n for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		} {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		} char[] org = sc.next().toCharArray(); org sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(org) Arrays.sort Arrays org arr[i] = new String(org) arr[i] arr i new String(org) Arrays.sort(arr) Arrays.sort Arrays arr long total = 0; total 0 long count = 1; count 1 String prev = ""; prev "" for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		} {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		} if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    } prev.equals(arr[i]) prev.equals prev arr[i] arr i {
		        count++;
		    } count++ count {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    } total += count * (count - 1) / 2 total count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 count = 1 count 1 prev = arr[i] prev arr[i] arr i total += count * (count - 1) / 2 total count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   }
} public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   }
} Main
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
		    char[] org = sc.next().toCharArray();
		    Arrays.sort(org);
		    arr[i] = new String(org);
		}
		Arrays.sort(arr);
		long total = 0;
		long count = 1;
		String prev = "";
		for (int i = 0; i < n; i++) {
		    if (prev.equals(arr[i])) {
		        count++;
		    } else {
		        total += count * (count - 1) / 2;
		        count = 1;
		        prev = arr[i];
		    }
		}
		total += count * (count - 1) / 2;
		System.out.println(total);
   }
}
