import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)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 HashMap<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() long ans = 0; ans 0 for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    } {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    } String s = sc.next(); s sc.next() sc.next sc String[] st = new String[10]; st new String[10] 10 for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      } {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      } String t = String.valueOf(s.charAt(j)); t String.valueOf(s.charAt(j)) String.valueOf String s.charAt(j) s.charAt s j st[j] = t st[j] st j t Arrays.sort(st) Arrays.sort Arrays st String m = ""; m "" for(int j = 0; j < 10; j++) {
        m += st[j];
      } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
        m += st[j];
      } {
        m += st[j];
      } m += st[j] m st[j] st j if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      } map.containsKey(m) map.containsKey map m {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } ans += (map.get(m)) ans (map.get(m)) map.get map m map.put(m, map.get(m) + 1) map.put map m map.get(m) + 1 map.get(m) map.get map m 1 {
        map.put(m, (long)1);
      } map.put(m, (long)1) map.put map m (long)1 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();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> map = new HashMap<String, Long>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      String[] st = new String[10];
      for(int j = 0; j < 10; j++) {
        String t = String.valueOf(s.charAt(j));
        st[j] = t;
      }
      Arrays.sort(st);
      String m = "";
      for(int j = 0; j < 10; j++) {
        m += st[j];
      }
      if(map.containsKey(m)) {
        ans += (map.get(m));
        map.put(m, map.get(m) + 1);
      } else {
        map.put(m, (long)1);
      }
    }
    System.out.println(ans);
  }
}