import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List<String> list = new ArrayList<>(); list new ArrayList<>() HashMap<String, Integer> hash = new HashMap<>(); hash new HashMap<>() long cnt = 0; cnt 0 for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        } {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        } List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList()); strList Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList()) Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()) Arrays.stream(sc.next().split("")).sorted Arrays.stream(sc.next().split("")) Arrays.stream Arrays sc.next().split("") sc.next().split sc.next() sc.next sc "" Comparator.naturalOrder() Comparator.naturalOrder Comparator Collectors.toList() Collectors.toList Collectors String str = String.join("", strList); str String.join("", strList) String.join String "" strList list.add(str) list.add list str if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            } hash.containsKey(str) hash.containsKey hash str {
                hash.put(str, hash.get(str) + 1);
            } hash.put(str, hash.get(str) + 1) hash.put hash str hash.get(str) + 1 hash.get(str) hash.get hash str 1 {
                hash.put(str, 1);
            } hash.put(str, 1) hash.put hash str 1 for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        } long c hash.values() hash.values hash {
            cnt += c * (c - 1) / 2;
        } {
            cnt += c * (c - 1) / 2;
        } cnt += c * (c - 1) / 2 cnt c * (c - 1) / 2 c * (c - 1) c (c - 1) c 1 2 System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
} Main
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
}