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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      String s = sc.next();
      String[] s_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    } {
      String s = sc.next();
      String[] s_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    } String s = sc.next(); s sc.next() sc.next sc String[] s_ = s.split(""); s_ s.split("") s.split s "" Arrays.sort(s_) Arrays.sort Arrays s_ String ss_ = ""; ss_ "" for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      } int j = 0; int j = 0; j 0 j < s_.length j s_.length s_ s_.length j++ j++ j {
        ss_ += s_[j];
      } {
        ss_ += s_[j];
      } ss_ += s_[j] ss_ s_[j] s_ j if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      } hashMap.containsKey(ss_) hashMap.containsKey hashMap ss_ {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } int v_ = hashMap.get(ss_); v_ hashMap.get(ss_) hashMap.get hashMap ss_ hashMap.put(ss_, v_ + 1) hashMap.put hashMap ss_ v_ + 1 v_ 1 {
        hashMap.put(ss_, 1);
      } hashMap.put(ss_, 1) hashMap.put hashMap ss_ 1 sc.close() sc.close sc long count = 0; count 0 for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      }
    } Integer value hashMap.values() hashMap.values hashMap {
      if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      }
    } {
      if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      }
    } if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      } 1 < value 1 value {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      } for (int i = 2; i <= value; i++) {
          count += i - 1;
        } int i = 2; int i = 2; i 2 i <= value i value 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; 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_ = s.split("");
      Arrays.sort(s_);
      String ss_ = "";
      for (int j = 0; j < s_.length; j++) {
        ss_ += s_[j];
      }
      if (hashMap.containsKey(ss_)) {
        int v_ = hashMap.get(ss_);
        hashMap.put(ss_, v_ + 1);
      } else {
        hashMap.put(ss_, 1);
      }
    }

    sc.close();

    long count = 0;

    for (Integer value : hashMap.values()) {
      if (1 < value) {
        for (int i = 2; i <= value; i++) {
          count += i - 1;
        }
      }
    }

    System.out.println(count);

  }

}