import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    } main {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in Map<String, Long> S = new HashMap<>(); S new HashMap<>() for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        } {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        } String[] s = in.next().split(""); s in.next().split("") in.next().split in.next() in.next in "" Arrays.sort(s) Arrays.sort Arrays s String ss = String.join("", s); ss String.join("", s) String.join String "" s if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            } !S.containsKey(ss) S.containsKey(ss) S.containsKey S ss {
                S.put(ss, 1L);
            } S.put(ss, 1L) S.put S ss 1L {
                S.put(ss, S.get(ss) + 1);
            } S.put(ss, S.get(ss) + 1) S.put S ss S.get(ss) + 1 S.get(ss) S.get S ss 1 long res = 0; res 0 for (long v : S.values()) {
            res += v * (v - 1) / 2;
        } long v S.values() S.values S {
            res += v * (v - 1) / 2;
        } {
            res += v * (v - 1) / 2;
        } res += v * (v - 1) / 2 res v * (v - 1) / 2 v * (v - 1) v (v - 1) v 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) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> S = new HashMap<>();

        for (int i = 0; i < N; i++) {
            String[] s = in.next().split("");
            Arrays.sort(s);
            String ss = String.join("", s);
            if (!S.containsKey(ss)) {
                S.put(ss, 1L);
            } else {
                S.put(ss, S.get(ss) + 1);
            }
        }

        long res = 0;
        for (long v : S.values()) {
            res += v * (v - 1) / 2;
        }

        System.out.println(res);
    }
}
