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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.util.HashMap; HashMap java.util public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String, Long> s = new HashMap<>(); s new HashMap<>() long count = 0; count 0 for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    } {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    } char[] ci = sc.next().toCharArray(); ci sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(ci) Arrays.sort Arrays ci String si = new String(ci); si new String(ci) s.put(si, s.getOrDefault(si, 0L) + 1) s.put s si s.getOrDefault(si, 0L) + 1 s.getOrDefault(si, 0L) s.getOrDefault s si 0L 1 for (long v : s.values()) {
      count += v * (v - 1) / 2;
    } long v s.values() s.values s {
      count += v * (v - 1) / 2;
    } {
      count += v * (v - 1) / 2;
    } count += v * (v - 1) / 2 count v * (v - 1) / 2 v * (v - 1) v (v - 1) v 1 2 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  }
} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  }
}