import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        } {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        } String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc List<String> list = new ArrayList<>(); list new ArrayList<>() for (Character c : str.toCharArray()) {
                list.add(c.toString());
            } Character c str.toCharArray() str.toCharArray str {
                list.add(c.toString());
            } {
                list.add(c.toString());
            } list.add(c.toString()) list.add list c.toString() c.toString c Collections.sort(list) Collections.sort Collections list StringJoiner sj = new StringJoiner(""); sj new StringJoiner("") for (String s : list) {
                sj.add(s);
            } String s list {
                sj.add(s);
            } {
                sj.add(s);
            } sj.add(s) sj.add sj s String key = sj.toString(); key sj.toString() sj.toString sj if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            } map.containsKey(key) map.containsKey map key {
                map.put(key, map.get(key)  + 1);
            } map.put(key, map.get(key)  + 1) map.put map key map.get(key)  + 1 map.get(key) map.get map key 1 {
                map.put(key, 1);
            } map.put(key, 1) map.put map key 1 sc.close() sc.close sc long count = 0; count 0 for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        } Map.Entry<String, Integer> entry map.entrySet() map.entrySet map {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        } {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        } int value = entry.getValue(); value entry.getValue() entry.getValue entry if (value >= 2) {
                count += combi(value);
            } value >= 2 value 2 {
                count += combi(value);
            } count += combi(value) count combi(value) combi value System.out.print(count) System.out.print System.out System System.out count String[] args args private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    } combi {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    } if (n <= 1) return 0; n <= 1 n 1 return 0; 0 return n * (n - 1) / 2; n * (n - 1) / 2 n * (n - 1) n (n - 1) n 1 2 long n n public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String str = sc.nextLine();
            List<String> list = new ArrayList<>();
            for (Character c : str.toCharArray()) {
                list.add(c.toString());
            }
            Collections.sort(list);
            StringJoiner sj = new StringJoiner("");
            for (String s : list) {
                sj.add(s);
            }
            String key = sj.toString();

            if (map.containsKey(key)) {
                map.put(key, map.get(key)  + 1);
            } else {
                map.put(key, 1);
            }

        }
        sc.close();

        long count = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (value >= 2) {
                count += combi(value);
            }
        }
        System.out.print(count);
    }

    private static long combi(long n) {
        if (n <= 1) return 0;
        return n * (n - 1) / 2;
    }
}