import java.util.*;
import java.io.*;
public class Main {
 public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
 public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 }
} Main public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 } main {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 } Scanner file = new Scanner(System.in); file new Scanner(System.in) int n = file.nextInt(); n file.nextInt() file.nextInt file HashMap<ArrayList<Character>, Integer> hm = new HashMap<>(); hm new HashMap<>() long t = 0; t 0 for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   } {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   } String s = file.next(); s file.next() file.next file ArrayList<Character> a = new ArrayList<>(); a new ArrayList<>() for (char c : s.toCharArray()) a.add(c); char c s.toCharArray() s.toCharArray s a.add(c); a.add(c) a.add a c Collections.sort(a) Collections.sort Collections a if (!hm.containsKey(a)) hm.put(a, 0); !hm.containsKey(a) hm.containsKey(a) hm.containsKey hm a hm.put(a, 0) hm.put hm a 0 t += hm.get(a) t hm.get(a) hm.get hm a hm.put(a, hm.get(a) + 1) hm.put hm a hm.get(a) + 1 hm.get(a) hm.get hm a 1 System.out.println(t) System.out.println System.out System System.out t String[] args args public class Main {
 public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 }
} public class Main {
 public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 }
} Main
import java.util.*;
import java.io.*;
public class Main {
 public static void main(String[] args) throws Exception {
   Scanner file = new Scanner(System.in);
   int n = file.nextInt();
   HashMap<ArrayList<Character>, Integer> hm = new HashMap<>();
   long t = 0;
   for (int i = 0; i < n; i++) {
     String s = file.next();
     ArrayList<Character> a = new ArrayList<>();
     for (char c : s.toCharArray()) a.add(c);
     Collections.sort(a);
     if (!hm.containsKey(a)) hm.put(a, 0);
     t += hm.get(a);
     hm.put(a, hm.get(a) + 1);
   }
   System.out.println(t);
 }
}
