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

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

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    } main {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in String s[] = new String[n]; s new String[n] n for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        } {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        } char[] cs = in.next().toCharArray(); cs in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(cs) Arrays.sort Arrays cs s[i] = new String(cs) s[i] s i new String(cs) Arrays.sort(s) Arrays.sort Arrays s String before = ""; before "" long same = 0; same 0 long total = 0; total 0 for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        } {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        } if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            } !s[i].equals(before) s[i].equals(before) s[i].equals s[i] s i before {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } total += same * (same - 1) / 2 total same * (same - 1) / 2 same * (same - 1) same (same - 1) same 1 2 same = 1 same 1 before = s[i] before s[i] s i {
                same++;
            } same++ same total += same * (same - 1) / 2 total same * (same - 1) / 2 same * (same - 1) same (same - 1) same 1 2 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s[] = new String[n];
        for (int i = 0; i < n; i++) {
            char[] cs = in.next().toCharArray();
            Arrays.sort(cs);
            s[i] = new String(cs);
        }

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

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

        Arrays.sort(s);

        String before = "";
        long same = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {
            if (!s[i].equals(before)) {
                total += same * (same - 1) / 2;
                same = 1;
                before = s[i];
            } else {
                same++;
            }
        }
        total += same * (same - 1) / 2;
        System.out.println(total);
    }
}