import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  }
  static int calc(String[] ss,int n,int f){
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  }
} import java.util.*; util.* java class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  }
  static int calc(String[] ss,int n,int f){
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  }
} Main public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  } main {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc StringBuffer s[]=new StringBuffer[n]; s new StringBuffer[n] n String ss[]=new String[n]; ss new String[n] n for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      s[i]=new StringBuffer(sc.next());
    } {
      s[i]=new StringBuffer(sc.next());
    } s[i]=new StringBuffer(sc.next()) s[i] s i new StringBuffer(sc.next()) for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    } {
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    } for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      } int j=1; int j=1; j 1 j<10 j 10 j++ j++ j {
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      } {
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      } for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        } int k=j; int k=j; k j k>0 k 0 k-- k-- k {
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        } {
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        } if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          } s[i].charAt(k)<s[i].charAt(k-1) s[i].charAt(k) s[i].charAt s[i] s i k s[i].charAt(k-1) s[i].charAt s[i] s i k-1 k 1 {
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          } char t=s[i].charAt(k); t s[i].charAt(k) s[i].charAt s[i] s i k s[i].setCharAt(k,s[i].charAt(k-1)) s[i].setCharAt s[i] s i k s[i].charAt(k-1) s[i].charAt s[i] s i k-1 k 1 s[i].setCharAt(k-1,t) s[i].setCharAt s[i] s i k-1 k 1 t ss[i]=new String(s[i]) ss[i] ss i new String(s[i]) Arrays.sort(ss) Arrays.sort Arrays ss long sum=0; sum 0 int kk=0; kk 0 int sk=0; sk 0 while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    } kk<n kk n {
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    } kk=calc(ss,n,sk) kk calc(ss,n,sk) calc ss n sk sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) sum sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) sum ( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) ((long)(kk-sk)*(long)((kk-sk)-1)) (long)(kk-sk) kk sk (long)((kk-sk)-1) (kk-sk) kk sk 1 2 sk=kk sk kk sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) sum sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) sum ( ((long)(kk-sk)*(long)((kk-sk)-1))/2 ) ((long)(kk-sk)*(long)((kk-sk)-1)) (long)(kk-sk) kk sk (long)((kk-sk)-1) (kk-sk) kk sk 1 2 System.out.println(sum) System.out.println System.out System System.out sum String args[] args static int calc(String[] ss,int n,int f){
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  } calc {
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  } for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    } int i=f+1; int i=f+1; i f+1 f 1 i<n i n i++ i++ i {
      if(!ss[f].equals(ss[i])){
        return i;
      }
    } {
      if(!ss[f].equals(ss[i])){
        return i;
      }
    } if(!ss[f].equals(ss[i])){
        return i;
      } !ss[f].equals(ss[i]) ss[f].equals(ss[i]) ss[f].equals ss[f] ss f ss[i] ss i {
        return i;
      } return i; i return n; n String[] ss ss int n n int f f
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    StringBuffer s[]=new StringBuffer[n];
    String ss[]=new String[n];
    for(int i=0;i<n;i++){
      s[i]=new StringBuffer(sc.next());
    }
    
    for(int i=0;i<n;i++){
      for(int j=1;j<10;j++){
        for(int k=j;k>0;k--){
          if(s[i].charAt(k)<s[i].charAt(k-1)){
            char t=s[i].charAt(k);
            s[i].setCharAt(k,s[i].charAt(k-1));
            s[i].setCharAt(k-1,t);
          }
        }
      }
      ss[i]=new String(s[i]);
    }
    Arrays.sort(ss);
    
    long sum=0;
    int kk=0;
    int sk=0;
    while(kk<n){
        kk=calc(ss,n,sk);
        sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
        sk=kk;
    }
    sum=sum+( ((long)(kk-sk)*(long)((kk-sk)-1))/2 );
    System.out.println(sum);
  }
  static int calc(String[] ss,int n,int f){
    for(int i=f+1;i<n;i++){
      if(!ss[f].equals(ss[i])){
        return i;
      }
    }
    return n;
  }
}