import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    }
} Main public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] strArray = new String[n]; strArray new String[n] n for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        } {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        } char[] ca = sc.next().toCharArray(); ca sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(ca) Arrays.sort Arrays ca strArray[i] = String.valueOf(ca) strArray[i] strArray i String.valueOf(ca) String.valueOf String ca sc.close() sc.close sc Arrays.sort(strArray) Arrays.sort Arrays strArray long count = 1; count 1 long res = 0; res 0 String before = ""; before "" String current = ""; current "" for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        } String str strArray {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        } {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        } before = current before current current = str current str if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            } before.equals(current) before.equals before current {
                count++;
            } count++ count {
                res += (count * (count - 1)) / 2;
                count = 1;
            } res += (count * (count - 1)) / 2 res (count * (count - 1)) / 2 (count * (count - 1)) count (count - 1) count 1 2 count = 1 count 1 res += (count * (count - 1)) / 2 res (count * (count - 1)) / 2 (count * (count - 1)) count (count - 1) count 1 2 System.out.print(res) System.out.print System.out System System.out res String[] args args
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    }
}
