import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    }

    static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    }

    static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    }
} Main static Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    } main {
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    } int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn String[] sortedS = new String[n]; sortedS new String[n] n for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        } {
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        } String s = stdIn.next(); s stdIn.next() stdIn.next stdIn char[] cs = s.toCharArray(); cs s.toCharArray() s.toCharArray s Arrays.sort(cs) Arrays.sort Arrays cs sortedS[i] = new String(cs) sortedS[i] sortedS i new String(cs) Arrays.sort(sortedS) Arrays.sort Arrays sortedS long cnt = 0; cnt 0 for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        } {
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        } if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            } !sortedS[i].equals(sortedS[i+1]) sortedS[i].equals(sortedS[i+1]) sortedS[i].equals sortedS[i] sortedS i sortedS[i+1] sortedS i+1 i 1 {
                continue;
            } continue; int j=i+1; j i+1 i 1 while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            } true {
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            } if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                } !sortedS[i].equals(sortedS[j]) sortedS[i].equals(sortedS[j]) sortedS[i].equals sortedS[i] sortedS i sortedS[j] sortedS j {
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                } while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    } !sortedS[i].equals(sortedS[j]) sortedS[i].equals(sortedS[j]) sortedS[i].equals sortedS[i] sortedS i sortedS[j] sortedS j {
                        j--;
                    } j-- j break; {
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                } j = j+100 j j+100 j 100 if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    } j>=n j n {
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    } j = n-1 j n-1 n 1 while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        } !sortedS[i].equals(sortedS[j]) sortedS[i].equals(sortedS[j]) sortedS[i].equals sortedS[i] sortedS i sortedS[j] sortedS j {
                            j--;
                        } j-- j break; cnt += nC2(j - i + 1) cnt nC2(j - i + 1) nC2 j - i + 1 j - i j i 1 i = j i j System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    } nC2 {
        return ((long)n * (long)(n-1)) / 2;
    } return ((long)n * (long)(n-1)) / 2; ((long)n * (long)(n-1)) / 2 ((long)n * (long)(n-1)) (long)n (long)(n-1) n 1 2 int n n public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    }

    static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    }
} public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    }

    static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    }
} Main
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        String[] sortedS = new String[n];
        for(int i=0; i<n; i++){
            String s = stdIn.next();
            char[] cs = s.toCharArray();
            Arrays.sort(cs);
            sortedS[i] = new String(cs);
        }
        
        Arrays.sort(sortedS);

        long cnt = 0;
        for(int i=0; i<n-1; i++){
            if(!sortedS[i].equals(sortedS[i+1])){
                continue;
            }

            int j=i+1;
            while(true){
                if(!sortedS[i].equals(sortedS[j])){
                    while(!sortedS[i].equals(sortedS[j])){
                        j--;
                    }
                    break;
                }else{
                    j = j+100;
                    if(j>=n){
                        j = n-1;
                        while(!sortedS[i].equals(sortedS[j])){
                            j--;
                        }
                        break;
                    }
                }
            }
            cnt += nC2(j - i + 1);
            i = j;
        }

        System.out.println(cnt);
    }

    static long nC2(int n){
        return ((long)n * (long)(n-1)) / 2;
    }
}
