import java.util.*;
import java.io.*;

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

        int N = sc.nextInt();

        long count = 0;
        Map<String, Integer> map = new HashMap<String, Integer>(N);
        for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        }
        sc.close();

        out.printf("%d\n", count);
        out.flush();
    }
} import java.util.*; util.* java import java.io.*; io.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();

        long count = 0;
        Map<String, Integer> map = new HashMap<String, Integer>(N);
        for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        }
        sc.close();

        out.printf("%d\n", count);
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();

        long count = 0;
        Map<String, Integer> map = new HashMap<String, Integer>(N);
        for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        }
        sc.close();

        out.printf("%d\n", count);
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();

        long count = 0;
        Map<String, Integer> map = new HashMap<String, Integer>(N);
        for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        }
        sc.close();

        out.printf("%d\n", count);
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long count = 0; count 0 Map<String, Integer> map = new HashMap<String, Integer>(N); map new HashMap<String, Integer>(N) for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        } {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        } char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(s) Arrays.sort Arrays s String S = String.valueOf(s); S String.valueOf(s) String.valueOf String s if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            } map.containsKey(S) map.containsKey map S {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } Integer temp = map.get(S); temp map.get(S) map.get map S count += temp.intValue() count temp.intValue() temp.intValue temp map.put(S, temp.intValue() + 1) map.put map S temp.intValue() + 1 temp.intValue() temp.intValue temp 1 {
                map.put(S, 1);
            } map.put(S, 1) map.put map S 1 sc.close() sc.close sc out.printf("%d\n", count) out.printf out "%d\n" count out.flush() out.flush out String[] args args
import java.util.*;
import java.io.*;

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

        int N = sc.nextInt();

        long count = 0;
        Map<String, Integer> map = new HashMap<String, Integer>(N);
        for (int i = 0; i < N; i++) {
            char[] s = sc.next().toCharArray();
            Arrays.sort(s);
            String S = String.valueOf(s);
            if (map.containsKey(S)) {
                Integer temp = map.get(S);
                count += temp.intValue();
                map.put(S, temp.intValue() + 1);
            } else {
                map.put(S, 1);
            }
        }
        sc.close();

        out.printf("%d\n", count);
        out.flush();
    }
}
