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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    }
} 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 public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    } main {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc int N = Integer.parseInt(line); N Integer.parseInt(line) Integer.parseInt Integer line Map<String, Integer> map = new HashMap<>(); map new HashMap<>() long count = 0; count 0 for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        } {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        } String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc char[] chars = input.toCharArray(); chars input.toCharArray() input.toCharArray input Arrays.sort(chars) Arrays.sort Arrays chars String sorted = String.valueOf(chars); sorted String.valueOf(chars) String.valueOf String chars if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            } map.containsKey(sorted) map.containsKey map sorted {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } count += map.get(sorted) count map.get(sorted) map.get map sorted map.put(sorted, map.get(sorted) + 1) map.put map sorted map.get(sorted) + 1 map.get(sorted) map.get map sorted 1 {
                map.put(sorted, 1);
            } map.put(sorted, 1) map.put map sorted 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    }
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int N = Integer.parseInt(line);
        Map<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < N; i++) {
            String input = sc.nextLine();
            char[] chars = input.toCharArray();
            Arrays.sort(chars);
            String sorted = String.valueOf(chars);
            if (map.containsKey(sorted)) {
                count += map.get(sorted);
                map.put(sorted, map.get(sorted) + 1);
            } else {
                map.put(sorted, 1);
            }
        }
        System.out.println(count);
    }
}