
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

 class Main {


    private static int min(int a, int b)
    {
        return (a < b) ? a : b;
    }


        static long binomialCoeff(int n, int k)
        {
            long C[][] = new long[n+1][k+1];
            int i, j;

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }

            return C[n][k];
        }


        public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();

        String[] strings=new String[n];
        for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        }
        Arrays.sort(strings);
        long count=0;
        for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        }
            System.out.println(count);


    }
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {


    private static int min(int a, int b)
    {
        return (a < b) ? a : b;
    }


        static long binomialCoeff(int n, int k)
        {
            long C[][] = new long[n+1][k+1];
            int i, j;

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }

            return C[n][k];
        }


        public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();

        String[] strings=new String[n];
        for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        }
        Arrays.sort(strings);
        long count=0;
        for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        }
            System.out.println(count);


    }
} Main private static int min(int a, int b)
    {
        return (a < b) ? a : b;
    } min {
        return (a < b) ? a : b;
    } return (a < b) ? a : b; (a < b) ? a : b (a < b) a b a b int a a int b b static long binomialCoeff(int n, int k)
        {
            long C[][] = new long[n+1][k+1];
            int i, j;

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }

            return C[n][k];
        } binomialCoeff {
            long C[][] = new long[n+1][k+1];
            int i, j;

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }

            return C[n][k];
        } long C[][] = new long[n+1][k+1]; C new long[n+1][k+1] n+1 n 1 k+1 k 1 int i i j; j for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            } i = 0; i = 0 i 0 i <= n i n i++ i++ i {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            } {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            } for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                } j = 0; j = 0 j 0 j <= min(i, k) j min(i, k) min i k j++ j++ j {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                } {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                } if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j]; j == 0 || j == i j == 0 j 0 j == i j i C[i][j] = 1 C[i][j] C[i] C i j 1 C[i][j] = C[i-1][j-1] + C[i-1][j] C[i][j] C[i] C i j C[i-1][j-1] + C[i-1][j] C[i-1][j-1] C[i-1] C i-1 i 1 j-1 j 1 C[i-1][j] C[i-1] C i-1 i 1 j return C[n][k]; C[n][k] C[n] C n k int n n int k k public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();

        String[] strings=new String[n];
        for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        }
        Arrays.sort(strings);
        long count=0;
        for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        }
            System.out.println(count);


    } main {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();

        String[] strings=new String[n];
        for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        }
        Arrays.sort(strings);
        long count=0;
        for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        }
            System.out.println(count);


    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in String[] strings=new String[n]; strings new String[n] n for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        } {
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        } char[] s=in.next().toCharArray(); s in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(s) Arrays.sort Arrays s strings[i]=new String(s) strings[i] strings i new String(s) Arrays.sort(strings) Arrays.sort Arrays strings long count=0; count 0 for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        } int i=1; int i=1; i 1 i<n i n {
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        } {
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        } long c=0; c 0 boolean flag=false; flag false while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            } i<n && strings[i].equals(strings[i-1]) i<n i n strings[i].equals(strings[i-1]) strings[i].equals strings[i] strings i strings[i-1] strings i-1 i 1 {
                flag=true;
                c++;
                i++;
            } flag=true flag true c++ c i++ i if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            } c>0 c 0 {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            } count+= (c*(c+1))/2 count (c*(c+1))/2 (c*(c+1)) c (c+1) c 1 2 if(!flag)
                i++; !flag flag i++ i System.out.println(count) System.out.println System.out System System.out count String[] args args

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

 class Main {


    private static int min(int a, int b)
    {
        return (a < b) ? a : b;
    }


        static long binomialCoeff(int n, int k)
        {
            long C[][] = new long[n+1][k+1];
            int i, j;

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= min(i, k); j++)
                {
                    if (j == 0 || j == i)
                        C[i][j] = 1;

                    else
                        C[i][j] = C[i-1][j-1] + C[i-1][j];
                }
            }

            return C[n][k];
        }


        public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();

        String[] strings=new String[n];
        for(int i=0;i<n;i++){
            char[] s=in.next().toCharArray();
            Arrays.sort(s);
            strings[i]=new String(s);
        }
        Arrays.sort(strings);
        long count=0;
        for(int i=1;i<n;){
            long c=0;
            boolean flag=false;
            while(i<n && strings[i].equals(strings[i-1])) {
                flag=true;
                c++;
                i++;
            }
            if(c>0) {
               // c++;
                //count += binomialCoeff(c, 2);
                count+= (c*(c+1))/2;
            }
            if(!flag)
                i++;

        }
            System.out.println(count);


    }
}
