import java.util.*;
 
public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
} Main static int[] list; list public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    } main {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      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 String[] s = new String[n]; s new String[n] n for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      } {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      } char[] chars = sc.next().toCharArray(); chars sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(chars) Arrays.sort Arrays chars s[i] = String.valueOf(chars) s[i] s i String.valueOf(chars) String.valueOf String chars Arrays.sort(s) Arrays.sort Arrays s long cnt = 0; cnt 0 long sum = 0; sum 0 for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      } {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      } if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        } s[i].equals(s[i+1]) s[i].equals s[i] s i s[i+1] s i+1 i 1 {
          sum++;
          cnt+=sum;
        } sum++ sum cnt+=sum cnt sum {
          sum=0;
        } sum=0 sum 0 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
} public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
} Main
import java.util.*;
 
public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for (int i = 0; i<n;i++) {
        char[] chars = sc.next().toCharArray();
        Arrays.sort(chars);
        s[i] = String.valueOf(chars);
      }
      Arrays.sort(s);
      long cnt = 0;
      long sum = 0;
      for(int i=0;i<n-1;i++) {
        if (s[i].equals(s[i+1])) {
          sum++;
          cnt+=sum;
        } else {
          sum=0;
        }
      }
      System.out.println(cnt);
    }
}
