import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan String [] g = new String[n]; g new String[n] n for (int i=0;i<n;i++){
      g[i] = scan.next();
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      g[i] = scan.next();
    } {
      g[i] = scan.next();
    } g[i] = scan.next() g[i] g i scan.next() scan.next scan HashMap<String,Integer> t = new HashMap<String,Integer>(); t new HashMap<String,Integer>() ArrayList<String> tt = new ArrayList<String>(); tt new ArrayList<String>() for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    } int j=0; int j=0; j 0 j<n j n j++ j++ j {
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    } {
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    } char[] gg = new char[10]; gg new char[10] 10 for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        } int k=0; int k=0; k 0 k<10 k 10 k++ k++ k {
          gg[k] = g[j].charAt(k);
        } {
          gg[k] = g[j].charAt(k);
        } gg[k] = g[j].charAt(k) gg[k] gg k g[j].charAt(k) g[j].charAt g[j] g j k Arrays.sort(gg) Arrays.sort Arrays gg String check = ""; check "" for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        } int p=0; int p=0; p 0 p<10 p 10 p++ p++ p {
          check += Character.toString(gg[p]);
        } {
          check += Character.toString(gg[p]);
        } check += Character.toString(gg[p]) check Character.toString(gg[p]) Character.toString Character gg[p] gg p if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        } t.get(check) == null t.get(check) t.get t check null {
          t.put(check,1);
          tt.add(check);
        } t.put(check,1) t.put t check 1 tt.add(check) tt.add tt check {
          int y = t.get(check);
          t.put(check,y+1);
        } int y = t.get(check); y t.get(check) t.get t check t.put(check,y+1) t.put t check y+1 y 1 long sum = 0; sum 0 for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    } int i=0; int i=0; i 0 i<tt.size() i tt.size() tt.size tt i++ i++ i {
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    } {
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    } int m = t.get(tt.get(i)); m t.get(tt.get(i)) t.get t tt.get(i) tt.get tt i sum += (long) m*(m-1)/2 sum (long) m*(m-1)/2 (long) m*(m-1) (long) m (m-1) m 1 2 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] g = new String[n];
    for (int i=0;i<n;i++){
      g[i] = scan.next();
    }
    HashMap<String,Integer> t = new HashMap<String,Integer>();
    ArrayList<String> tt = new ArrayList<String>();

    for (int j=0;j<n;j++){
        char[] gg = new char[10];
        for (int k=0;k<10;k++){
          gg[k] = g[j].charAt(k);
        }
        Arrays.sort(gg);
        String check = "";
        for (int p=0;p<10;p++){
          check += Character.toString(gg[p]);
        }
        if (t.get(check) == null){
          t.put(check,1);
          tt.add(check);
        }
        else{
          int y = t.get(check);
          t.put(check,y+1);
        }
    }


    long sum = 0;
    for (int i=0;i<tt.size();i++){
      int m = t.get(tt.get(i));
      sum += (long) m*(m-1)/2;
    }
    System.out.println(sum);

  }
}
