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