import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import static java.lang.Math.min;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    }


    private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util import static java.lang.Math.min; import static java.lang.Math.min; import static java.lang.Math.min; public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    }


    private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    } main {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) Map<String, Integer> count = new HashMap<>(); count new HashMap<>() int n = in.nextInt(); n in.nextInt() in.nextInt in for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        } {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        } String s = sort(in.next()); s sort(in.next()) sort in.next() in.next in if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            } count.containsKey(s) count.containsKey count s {
                count.replace(s, count.get(s) + 1);
            } count.replace(s, count.get(s) + 1) count.replace count s count.get(s) + 1 count.get(s) count.get count s 1 {
                count.put(s, 1);
            } count.put(s, 1) count.put count s 1 long res = 0; res 0 for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        } Map.Entry<String, Integer> kv count.entrySet() count.entrySet count {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        } {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        } res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2 res (long)kv.getValue() * (long)(kv.getValue() - 1) / 2 (long)kv.getValue() * (long)(kv.getValue() - 1) (long)kv.getValue() kv.getValue kv (long)(kv.getValue() - 1) kv.getValue() kv.getValue kv 1 2 System.out.println(res) System.out.println System.out System System.out res String[] args args private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    } sort {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    } char[]chars = text.toCharArray(); chars text.toCharArray() text.toCharArray text Arrays.sort(chars) Arrays.sort Arrays chars return new String(chars); new String(chars) String text text public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    }


    private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    }


    private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import static java.lang.Math.min;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> count = new HashMap<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sort(in.next());
            if (count.containsKey(s)) {
                count.replace(s, count.get(s) + 1);
            } else {
                count.put(s, 1);
            }
        }
        long res = 0;
        for (Map.Entry<String, Integer> kv : count.entrySet()) {
            res += (long)kv.getValue() * (long)(kv.getValue() - 1) / 2;
        }

        System.out.println(res);
    }


    private static String sort(String text) {
        char[]chars = text.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
}
