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);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
} 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);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    } main {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Map<String, Long> m = new HashMap<>(); m new HashMap<>() for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        } {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        } char[] c = sc.nextLine().toCharArray(); c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc Arrays.sort(c) Arrays.sort Arrays c String k = new String(c); k new String(c) if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            } m.get(k) == null m.get(k) m.get m k null {
                m.put(k, 1L);
            } m.put(k, 1L) m.put m k 1L {
                m.put(k, m.get(k) + 1);
            } m.put(k, m.get(k) + 1) m.put m k m.get(k) + 1 m.get(k) m.get m k 1 long ans = 0; ans 0 for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        } Long v m.values() m.values m {
            ans += v * (v - 1) / 2;
        } {
            ans += v * (v - 1) / 2;
        } ans += v * (v - 1) / 2 ans v * (v - 1) / 2 v * (v - 1) v (v - 1) v 1 2 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 sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
} 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);
        int N = Integer.parseInt(sc.nextLine());
        Map<String, Long> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            String k = new String(c);
            if (m.get(k) == null) {
                m.put(k, 1L);
            } else {
                m.put(k, m.get(k) + 1);
            }
        }
        long ans = 0;
        for (Long v : m.values()) {
            ans += v * (v - 1) / 2;
        }

        System.out.println(ans);
    }
}
