import java.util.*;

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

    int n = sc.nextInt();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    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();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    System.out.println(ans);
  }
} Main public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    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 String[] s = new String[n+1]; s new String[n+1] n+1 n 1 Map<String, Integer> list = new HashMap<>(); list new HashMap<>() for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    } {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    } char[] t = sc.next().toCharArray(); t sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(t) Arrays.sort Arrays t s[i] = "" s[i] s i "" for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
        s[i] += String.valueOf(t[j]);
      } {
        s[i] += String.valueOf(t[j]);
      } s[i] += String.valueOf(t[j]) s[i] s i String.valueOf(t[j]) String.valueOf String t[j] t j list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1)) list.put list s[i] s i (list.get(s[i]) == null ? 0 : list.get(s[i])+1) list.get(s[i]) == null list.get(s[i]) list.get list s[i] s i null 0 list.get(s[i])+1 list.get(s[i]) list.get list s[i] s i 1 long ans = 0; ans 0 for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    } Map.Entry<String, Integer> entry list.entrySet() list.entrySet list {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    } {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    } int cnt = entry.getValue(); cnt entry.getValue() entry.getValue entry for (int i = 0; i <= cnt; i++) {
        ans += i;
      } int i = 0; int i = 0; i 0 i <= cnt i cnt i++ i++ i {
        ans += i;
      } {
        ans += i;
      } ans += i ans i 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();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    System.out.println(ans);
  }
} public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    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();
    String[] s = new String[n+1];

    Map<String, Integer> list = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      char[] t = sc.next().toCharArray();
      Arrays.sort(t);
      s[i] = "";
      for (int j = 0; j < 10; j++) {
        s[i] += String.valueOf(t[j]);
      }
      list.put(s[i], (list.get(s[i]) == null ? 0 : list.get(s[i])+1));
    }

    long ans = 0;
    for (Map.Entry<String, Integer> entry: list.entrySet()) {
      int cnt = entry.getValue();
      for (int i = 0; i <= cnt; i++) {
        ans += i;
      }
    }
    
    System.out.println(ans);
  }
}
