import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    }
} import java.util.Scanner; Scanner java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Arrays; Arrays java.util import java.io.PrintWriter; PrintWriter java.io public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    }
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    } main {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int num = Integer.parseInt(sc.next()); num Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      } int i = 0; int i = 0; i 0 i<num i num i++ i++ i {
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      } {
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      } char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String str = String.valueOf(c); str String.valueOf(c) String.valueOf String c if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1); map.containsKey(str) map.containsKey map str {
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        } int v = map.get(str); v map.get(str) map.get map str ans += v ans v map.put(str,v+1) map.put map str v+1 v 1 map.put(str,1) map.put map str 1 out.println(ans) out.println out ans out.flush() out.flush out String[] args args public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    }
} public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    }
} Main
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      int num = Integer.parseInt(sc.next());
      Map<String, Integer> map = new HashMap<>();
      long ans = 0;
      for(int i = 0;i<num;i++){
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        String str = String.valueOf(c);
        if(map.containsKey(str)){
          int v = map.get(str);
          ans += v;
          map.put(str,v+1);
        }else map.put(str,1);
      }
      out.println(ans);
      out.flush();
    }
}
