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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  } main {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner String[] s = new String[N]; s new String[N] N for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    } {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    } char[] ch = scanner.next().toCharArray(); ch scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner Arrays.sort(ch) Arrays.sort Arrays ch s[i] = new String(ch) s[i] s i new String(ch) Arrays.sort(s) Arrays.sort Arrays s long count = 0; count 0 for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    } int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    } {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    } int j = i; j i while (j < N && s[i].equals(s[j])) j++; j < N && s[i].equals(s[j]) j < N j N s[i].equals(s[j]) s[i].equals s[i] s i s[j] s j j++ j long n = j - i; n j - i j i count += n * (n - 1) / 2 count n * (n - 1) / 2 n * (n - 1) n (n - 1) n 1 2 i = j i j 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 scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    String[] s = new String[N];
    for (int i = 0; i < N; i++) {
      char[] ch = scanner.next().toCharArray();
      Arrays.sort(ch);
      s[i] = new String(ch);
    }
    Arrays.sort(s);

    long count = 0;
    for (int i = 0; i < N - 1;) {
      int j = i;
      while (j < N && s[i].equals(s[j])) j++;
      long n = j - i;
      count += n * (n - 1) / 2;
      i = j;
    }
    System.out.println(count);
  }
}
