    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Scanner;
    import java.util.Map;
    class Main{
      public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       HashMap<String,Integer> ars = new HashMap<>();
       long a = 0L;
       for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       }
       System.out.println(a);
      }
    } import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util import java.util.Map; Map java.util class Main{
      public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       HashMap<String,Integer> ars = new HashMap<>();
       long a = 0L;
       for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       }
       System.out.println(a);
      }
    } Main public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       HashMap<String,Integer> ars = new HashMap<>();
       long a = 0L;
       for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       }
       System.out.println(a);
      } main {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       HashMap<String,Integer> ars = new HashMap<>();
       long a = 0L;
       for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       }
       System.out.println(a);
      } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String,Integer> ars = new HashMap<>(); ars new HashMap<>() long a = 0L; a 0L for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       } {
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       } char[] input = sc.next().toCharArray(); input sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(input) Arrays.sort Arrays input String str = String.valueOf(input); str String.valueOf(input) String.valueOf String input int cnt=0; cnt 0 if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } ars.containsKey(str) ars.containsKey ars str {
           cnt = ars.get(str);
           a += cnt;
         } cnt = ars.get(str) cnt ars.get(str) ars.get ars str a += cnt a cnt ars.put(str,cnt+1) ars.put ars str cnt+1 cnt 1 System.out.println(a) System.out.println System.out System System.out a String[] args args
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Scanner;
    import java.util.Map;
    class Main{
      public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       HashMap<String,Integer> ars = new HashMap<>();
       long a = 0L;
       for(int i = 0; i < n; i++){
         char[] input = sc.next().toCharArray();
         Arrays.sort(input);
         String str = String.valueOf(input);
         int cnt=0;
         if(ars.containsKey(str)){
           cnt = ars.get(str);
           a += cnt;
         } 
         ars.put(str,cnt+1);
       }
       System.out.println(a);
      }
    }