import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    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 = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  } Scanner sc =  new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc List<String> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    } {
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    } String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c s = new String(c) s new String(c) list.add(s) list.add list s Collections.sort(list) Collections.sort Collections list long ans = 0; ans 0 long count = 0; count 0 String t = ""; t "" String u = ""; u "" boolean check = false; check false for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    } {
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    } check = false check false if(i == 0){
        t = list.get(i);
        count++;
        continue;
      } i == 0 i 0 {
        t = list.get(i);
        count++;
        continue;
      } t = list.get(i) t list.get(i) list.get list i count++ count continue; u = list.get(i) u list.get(i) list.get list i if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      } t.equals(u) && i < N-1 t.equals(u) t.equals t u i < N-1 i N-1 N 1 {
        count++;
      } count++ count if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      } t.equals(u) && i == N-1 t.equals(u) t.equals t u i == N-1 i N-1 N 1 {
        count++;
        check = true;
      } count++ count check = true check true {
        t = u;
        check = true;
      } t = u t u check = true check true if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      } check {
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      } ans += (count*(count-1))/2 ans (count*(count-1))/2 (count*(count-1)) count (count-1) count 1 2 t = u t u count = 1 count 1 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 = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    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 = Integer.parseInt(sc.nextLine());
    List<String> list = new ArrayList<>();
    
    for(int i = 0; i < N; i++){
      String s = sc.nextLine();
      char[] c = s.toCharArray();
      Arrays.sort(c);
      s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    
    long ans = 0;
    long count = 0;
    String t = "";
    String u = "";
    boolean check = false;
    for(int i = 0; i < N; i++){
      check = false;
      if(i == 0){
        t = list.get(i);
        count++;
        continue;
      }
      
      u = list.get(i);
      if(t.equals(u) && i < N-1){
        count++;
      }else if(t.equals(u) && i == N-1){
        count++;
        check = true;
      }else{
        t = u;
        check = true;
      }
      
      if(check){
        ans += (count*(count-1))/2;
        t = u;
        count = 1;
      }
    }
    System.out.println(ans);
  }
}