import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    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 Map<String, Integer> mm = new HashMap<>(); mm new HashMap<>() for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    } {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    } char[] a = sc.next().toCharArray(); a sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(a) Arrays.sort Arrays a String s = Arrays.toString(a); s Arrays.toString(a) Arrays.toString Arrays a mm.put(s, mm.getOrDefault(s, 0) + 1) mm.put mm s mm.getOrDefault(s, 0) + 1 mm.getOrDefault(s, 0) mm.getOrDefault mm s 0 1 long ans = 0; ans 0 for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    } int v mm.values() mm.values mm {
      if (v >= 2) {
        ans += sum(v-1);
      }
    } {
      if (v >= 2) {
        ans += sum(v-1);
      }
    } if (v >= 2) {
        ans += sum(v-1);
      } v >= 2 v 2 {
        ans += sum(v-1);
      } ans += sum(v-1) ans sum(v-1) sum v-1 v 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  } sum {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  } if (v == 1) {
      return 1;
    } v == 1 v 1 {
      return 1;
    } return 1; 1 return v + sum(v-1); v + sum(v-1) v sum(v-1) sum v-1 v 1 int v v public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
}
