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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
}

// nC2 = n * (n-1) / 2 import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    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 long ans = 0; ans 0 String[] S = new String[N]; S new String[N] N HashMap<String, Long> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    } {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    } S[i] = sc.next() S[i] S i sc.next() sc.next sc char[] s = S[i].toCharArray(); s S[i].toCharArray() S[i].toCharArray S[i] S i Arrays.sort(s) Arrays.sort Arrays s S[i] = new String(s) S[i] S i new String(s) Long cnt = map.getOrDefault(S[i], 0L); cnt map.getOrDefault(S[i], 0L) map.getOrDefault map S[i] S i 0L map.put(S[i], cnt + 1) map.put map S[i] S i cnt + 1 cnt 1 for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    } Long n map.values() map.values map {
      ans += n * (n-1) / 2;
    } {
      ans += n * (n-1) / 2;
    } ans += n * (n-1) / 2 ans n * (n-1) / 2 n * (n-1) n (n-1) n 1 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;
    String[] S = new String[N];
    HashMap<String, Long> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      S[i] = sc.next();
      char[] s = S[i].toCharArray();
      Arrays.sort(s);
      S[i] = new String(s);
      Long cnt = map.getOrDefault(S[i], 0L);
      map.put(S[i], cnt + 1);
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        if (S[i].equals(S[j])) {
//          ans++;
//        }
//      }
//    }
    for (Long n : map.values()) {
      ans += n * (n-1) / 2;
    }
    System.out.println(ans);
  }
}

// nC2 = n * (n-1) / 2