import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 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, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 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, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() long ans = 0; ans 0 for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    } {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    } String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c String s2 = new String(c); s2 new String(c) if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      } map.containsKey(s2) map.containsKey map s2 {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } ans += (long)map.get(s2) ans (long)map.get(s2) map.get map s2 map.put(s2, map.get(s2) + 1) map.put map s2 map.get(s2) + 1 map.get(s2) map.get map s2 1 {
        map.put(s2, 1);
      } map.put(s2, 1) map.put map s2 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, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 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, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 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, Integer> map = new HashMap<String, Integer>();
    long ans = 0;
    for(int i = 0; i < n; i++) {
      String s = sc.next();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      String s2 = new String(c);
      if(map.containsKey(s2)) {
        ans += (long)map.get(s2);
        map.put(s2, map.get(s2) + 1);
      } else {
        map.put(s2, 1);
      }
    }
    System.out.println(ans);
  }
}