import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String[] s = new String[N]; s new String[N] N char[] chars = new char[10]; chars new char[10] 10 StringBuilder sb; sb for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    } {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    } sc.next().getChars(0, 10, chars, 0) sc.next().getChars sc.next() sc.next sc 0 10 chars 0 Arrays.sort(chars) Arrays.sort Arrays chars sb = new StringBuilder() sb new StringBuilder() for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
        sb.append(chars[j]);
      } {
        sb.append(chars[j]);
      } sb.append(chars[j]) sb.append sb chars[j] chars j s[i] = sb.toString() s[i] s i sb.toString() sb.toString sb Arrays.sort(s) Arrays.sort Arrays s long count = 1; count 1 long sum = 0; sum 0 for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    } {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    } if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      } s[i].equals(s[i-1]) s[i].equals s[i] s i s[i-1] s i-1 i 1 {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } count++ count if (i == N-1) {
          sum += count * (count - 1);
        } i == N-1 i N-1 N 1 {
          sum += count * (count - 1);
        } sum += count * (count - 1) sum count * (count - 1) count (count - 1) count 1 {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      } if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        } count == 1 count 1 {
          continue;
        } continue; {
          sum += count * (count - 1);
          count = 1;
        } sum += count * (count - 1) sum count * (count - 1) count (count - 1) count 1 count = 1 count 1 System.out.println(sum / 2) System.out.println System.out System System.out sum / 2 sum 2 String[] args args
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  }
}