import java.util.*;

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

    long cnt = 0;

    HashMap<String, Integer> a = new HashMap<>(n);

    for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    }
    System.out.println(cnt);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    long cnt = 0;

    HashMap<String, Integer> a = new HashMap<>(n);

    for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    }
    System.out.println(cnt);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    long cnt = 0;

    HashMap<String, Integer> a = new HashMap<>(n);

    for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    }
    System.out.println(cnt);
  } main {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    long cnt = 0;

    HashMap<String, Integer> a = new HashMap<>(n);

    for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    }
    System.out.println(cnt);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long cnt = 0; cnt 0 HashMap<String, Integer> a = new HashMap<>(n); a new HashMap<>(n) for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    } {
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    } String str = sc.next(); str sc.next() sc.next sc char[] aa = str.toCharArray(); aa str.toCharArray() str.toCharArray str Arrays.sort(aa) Arrays.sort Arrays aa String newStr = new String(aa); newStr new String(aa) if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      } a.containsKey(newStr) a.containsKey a newStr {
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      } cnt+=a.get(newStr) cnt a.get(newStr) a.get a newStr a.put(newStr, a.get(newStr)+1) a.put a newStr a.get(newStr)+1 a.get(newStr) a.get a newStr 1 {
          a.put(newStr, 1);
      } a.put(newStr, 1) a.put a newStr 1 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args
import java.util.*;

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

    long cnt = 0;

    HashMap<String, Integer> a = new HashMap<>(n);

    for(int i=0 ; i<n ; i++){
      String str = sc.next();
      char[] aa = str.toCharArray();
      Arrays.sort(aa);
      String newStr = new String(aa);
      if(a.containsKey(newStr)){
          cnt+=a.get(newStr);
          a.put(newStr, a.get(newStr)+1);
      }else{
          a.put(newStr, 1);
      }
    }
    System.out.println(cnt);
  }
}