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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    }
} Main public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        } {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.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++) {
                S[i] = in.next();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                S[i] = in.next();
            } {
                S[i] = in.next();
            } S[i] = in.next() S[i] S i in.next() in.next in ArrayList<String> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            } {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            } char[] cs = S[i].toCharArray(); cs S[i].toCharArray() S[i].toCharArray S[i] S i Arrays.sort(cs) Arrays.sort Arrays cs list.add(new String(cs)) list.add list new String(cs) Collections.sort(list) Collections.sort Collections list long res = 0; res 0 long count = 1; count 1 for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            } int i = 1; int i = 1; i 1 i < list.size() i list.size() list.size list i++ i++ i {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            } {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            } if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                } list.get(i - 1).equals(list.get(i)) list.get(i - 1).equals list.get(i - 1) list.get list i - 1 i 1 list.get(i) list.get list i {
                    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.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    }
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = in.next();
            }

            ArrayList<String> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                char[] cs = S[i].toCharArray();
                Arrays.sort(cs);
                list.add(new String(cs));
            }
            Collections.sort(list);

            long res = 0;
            long count = 1;
            for (int i = 1; i < list.size(); i++) {
                if (list.get(i - 1).equals(list.get(i))) {
                    count++;
                } else {
                    res += (count * (count - 1)) / 2;
                    count = 1;
                }
            }
            res += (count * (count - 1)) / 2;

            System.out.println(res);
        }
    }
}
