import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc char[][] SCA = new char[N][10]; SCA new char[N][10] N 10 long cnt = 0; cnt 0 Map<String, Long> sMap = new HashMap<>(); sMap new HashMap<>() for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        } {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        } SCA[i] = sc.next().toCharArray() SCA[i] SCA i sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(SCA[i]) Arrays.sort Arrays SCA[i] SCA i String si = new String(SCA[i]); si new String(SCA[i]) sMap.put(si, sMap.getOrDefault(si, 0L) + 1) sMap.put sMap si sMap.getOrDefault(si, 0L) + 1 sMap.getOrDefault(si, 0L) sMap.getOrDefault sMap si 0L 1 for (long n : sMap.values())
            cnt += n * (n - 1) / 2; long n sMap.values() sMap.values sMap cnt += n * (n - 1) / 2; cnt += n * (n - 1) / 2 cnt n * (n - 1) / 2 n * (n - 1) n (n - 1) n 1 2 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[][] SCA = new char[N][10];
        long cnt = 0;
        Map<String, Long> sMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            SCA[i] = sc.next().toCharArray();
            Arrays.sort(SCA[i]);
            String si = new String(SCA[i]);
            sMap.put(si, sMap.getOrDefault(si, 0L) + 1);
        }

        for (long n : sMap.values())
            cnt += n * (n - 1) / 2;

        System.out.println(cnt);


    }
}