import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    }
    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<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 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 HashMap<Long, Long> map = new HashMap<Long, Long>(); map new HashMap<Long, Long>() for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    } {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    } String s = sc.next(); s sc.next() sc.next sc ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      } int j = 0; int j = 0; j 0 j < s.length() j s.length() s.length s j++ j++ j {
        int t = s.charAt(j) - 'a';
        list.add(t);
      } {
        int t = s.charAt(j) - 'a';
        list.add(t);
      } int t = s.charAt(j) - 'a'; t s.charAt(j) - 'a' s.charAt(j) s.charAt s j 'a' list.add(t) list.add list t Collections.sort(list) Collections.sort Collections list long t = 0; t 0 for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      } int j = 0; int j = 0; j 0 j < list.size() j list.size() list.size list j++ j++ j {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      } {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      } t += ((long)(Math.pow(26, j)) * (long)list.get(j)) t ((long)(Math.pow(26, j)) * (long)list.get(j)) (long)(Math.pow(26, j)) Math.pow Math 26 j (long)list.get(j) list.get list j if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      } map.containsKey(t) map.containsKey map t {
        map.put(t, map.get(t) + 1);
      } map.put(t, map.get(t) + 1) map.put map t map.get(t) + 1 map.get(t) map.get map t 1 {
        map.put(t, (long)1);
      } map.put(t, (long)1) map.put map t (long)1 long ans = 0; ans 0 for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    } long key map.keySet() map.keySet map {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    } {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    } long t = map.get(key); t map.get(key) map.get map key ans += ((t * (t - 1)) / 2) ans ((t * (t - 1)) / 2) (t * (t - 1)) t (t - 1) t 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();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 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();
    HashMap<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    }
    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<Long, Long> map = new HashMap<Long, Long>();
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < s.length(); j++) {
        int t = s.charAt(j) - 'a';
        list.add(t);
      }
      Collections.sort(list);
      long t = 0;
      for(int j = 0; j < list.size(); j++) {
        t += ((long)(Math.pow(26, j)) * (long)list.get(j));
      }
      if(map.containsKey(t)) {
        map.put(t, map.get(t) + 1);
      } else {
        map.put(t, (long)1);
      }
    }
    long ans = 0;
    for(long key : map.keySet()) {
      long t = map.get(key);
      ans += ((t * (t - 1)) / 2);
    }
    System.out.println(ans);
  }
}
