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 in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
} 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 in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    } main {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in Map<String, Long> cnt = new HashMap<>(); cnt new HashMap<>() String[] words = new String[N]; words new String[N] N for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        } int i = 0; int i = 0; i 0 i < words.length i words.length words words.length i++ i++ i {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        } {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        } String word = in.next(); word in.next() in.next in char[] arr = word.toCharArray(); arr word.toCharArray() word.toCharArray word Arrays.sort(arr) Arrays.sort Arrays arr String sorted = String.valueOf(arr); sorted String.valueOf(arr) String.valueOf String arr cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1) cnt.put cnt sorted cnt.getOrDefault(sorted, (long) 0) + 1 cnt.getOrDefault(sorted, (long) 0) cnt.getOrDefault cnt sorted (long) 0 1 long res = 0; res 0 for (Long i : cnt.values())
            res += i * (i - 1) / 2; Long i cnt.values() cnt.values cnt res += i * (i - 1) / 2; res += i * (i - 1) / 2 res i * (i - 1) / 2 i * (i - 1) i (i - 1) i 1 2 System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
} 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 in = new Scanner(System.in);
        int N = in.nextInt();
        Map<String, Long> cnt = new HashMap<>();
        String[] words = new String[N];

        for (int i = 0; i < words.length; i++) {
            String word = in.next();
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }

        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
}
