import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        } {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        } String line = scanner.nextLine(); line scanner.nextLine() scanner.nextLine scanner char[] c = line.toCharArray(); c line.toCharArray() line.toCharArray line Arrays.sort(c) Arrays.sort Arrays c String sortedLine = new String(c); sortedLine new String(c) if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            } map.containsKey(sortedLine) map.containsKey map sortedLine {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } ans += map.get(sortedLine) ans map.get(sortedLine) map.get map sortedLine map.put(sortedLine, map.get(sortedLine) + 1) map.put map sortedLine map.get(sortedLine) + 1 map.get(sortedLine) map.get map sortedLine 1 {
                map.put(sortedLine, 1);
            } map.put(sortedLine, 1) map.put map sortedLine 1 System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
}
