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> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  }

} 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> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  }

} Main public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  } main {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc HashMap<String, Integer> hashMap = new HashMap<>(); hashMap new HashMap<>() for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    } {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    } String s_ = sc.next(); s_ sc.next() sc.next sc String[] s_array = s_.split(""); s_array s_.split("") s_.split s_ "" Arrays.sort(s_array) Arrays.sort Arrays s_array String key = ""; key "" for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      } int j = 0; int j = 0; j 0 j < s_array.length j s_array.length s_array s_array.length j++ j++ j {
        key += s_array[j];
      } {
        key += s_array[j];
      } key += s_array[j] key s_array[j] s_array j if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      } hashMap.containsKey(key) hashMap.containsKey hashMap key {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } int v_ = hashMap.get(key); v_ hashMap.get(key) hashMap.get hashMap key hashMap.put(key, v_ + 1) hashMap.put hashMap key v_ + 1 v_ 1 {
        hashMap.put(key, 1);
      } hashMap.put(key, 1) hashMap.put hashMap key 1 sc.close() sc.close sc long count = 0; count 0 for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    } Map.Entry<String, Integer> map hashMap.entrySet() hashMap.entrySet hashMap {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    } {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    } for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      } int i = 1; int i = 1; i 1 i <= map.getValue() i map.getValue() map.getValue map i++ i++ i {
        count += i - 1;
      } {
        count += i - 1;
      } count += i - 1 count i - 1 i 1 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 sc = new Scanner(System.in);

    int N = sc.nextInt();
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  }

} public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  }

} 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> hashMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      String[] s_array = s_.split("");
      Arrays.sort(s_array);
      String key = "";
      for (int j = 0; j < s_array.length; j++) {
        key += s_array[j];
      }
      if (hashMap.containsKey(key)) {
        int v_ = hashMap.get(key);
        hashMap.put(key, v_ + 1);
      } else {
        hashMap.put(key, 1);
      }
      
    }

    sc.close();

    long count = 0;

    for (Map.Entry<String, Integer> map : hashMap.entrySet()) {

      for (int i = 1; i <= map.getValue(); i++) {
        count += i - 1;
      }
    
    }

    System.out.println(count);

  }

}