import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

} import java.util.*; util.* java import java.math.*; math.* java import java.lang.*; lang.* java public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)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 String[] data = new String[n]; data new String[n] n HashMap<String, Long> map = new HashMap<>(); map new HashMap<>() long count = 0; count 0 for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      data[i] = sc.next();
    } {
      data[i] = sc.next();
    } data[i] = sc.next() data[i] data i sc.next() sc.next sc for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    } {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    } char[] temp = data[i].toCharArray(); temp data[i].toCharArray() data[i].toCharArray data[i] data i Arrays.sort(temp) Arrays.sort Arrays temp String str = String.valueOf(temp); str String.valueOf(temp) String.valueOf String temp if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      } map.containsKey(str) map.containsKey map str {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } long k = map.get(str); k map.get(str) map.get map str count += k count k map.put(str,k+1) map.put map str k+1 k 1 {
        map.put(str,(long)1);
      } map.put(str,(long)1) map.put map str (long)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();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

} Main
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] data = new String[n];

    HashMap<String, Long> map = new HashMap<>();

    long count = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.next();
    }

    for (int i = 0; i < n; i++) {
      char[] temp = data[i].toCharArray();
      Arrays.sort(temp);
      String str = String.valueOf(temp);
      if (map.containsKey(str)) {
        long k = map.get(str);
        count += k;
        map.put(str,k+1);
      } else {
        map.put(str,(long)1);
      }
    }

    System.out.println(count);


  }

}
