import java.util.Arrays;
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String str[] = new String[n]; str new String[n] n for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        } {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        } str[i] = "" str[i] str i "" String s = sc.next(); s sc.next() sc.next sc String tmp[] = new String[10]; tmp new String[10] 10 for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
                tmp[j] = s.substring(j, j + 1);
            } {
                tmp[j] = s.substring(j, j + 1);
            } tmp[j] = s.substring(j, j + 1) tmp[j] tmp j s.substring(j, j + 1) s.substring s j j + 1 j 1 Arrays.sort(tmp) Arrays.sort Arrays tmp for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
                str[i] = str[i] + tmp[j];
            } {
                str[i] = str[i] + tmp[j];
            } str[i] = str[i] + tmp[j] str[i] str i str[i] + tmp[j] str[i] str i tmp[j] tmp j Arrays.sort(str) Arrays.sort Arrays str long ans = 0; ans 0 long tmp = 1; tmp 1 for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        } int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        } {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        } while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            } str[i].equals(str[i + 1]) str[i].equals str[i] str i str[i + 1] str i + 1 i 1 {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            } tmp++ tmp i++ i if (i == n - 1) {
                    break;
                } i == n - 1 i n - 1 n 1 {
                    break;
                } break; ans += tmp * (tmp - 1) / 2 ans tmp * (tmp - 1) / 2 tmp * (tmp - 1) tmp (tmp - 1) tmp 1 2 tmp = 1 tmp 1 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args
import java.util.Arrays;
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    }
}
