
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 scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    }
} 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 scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    }
} Main public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner Map<String, Long> counts = new HashMap<>(); counts new HashMap<>() for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        } {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        } String s = scanner.next(); s scanner.next() scanner.next scanner char[] tmp = s.toCharArray(); tmp s.toCharArray() s.toCharArray s Arrays.sort(tmp) Arrays.sort Arrays tmp s = new String(tmp) s new String(tmp) long count = counts.getOrDefault(s, 0L); count counts.getOrDefault(s, 0L) counts.getOrDefault counts s 0L counts.put(s, count + 1L) counts.put counts s count + 1L count 1L long pairs = 0; pairs 0 for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        } long count counts.values() counts.values counts {
            pairs += (count * (count - 1L) / 2);
        } {
            pairs += (count * (count - 1L) / 2);
        } pairs += (count * (count - 1L) / 2) pairs (count * (count - 1L) / 2) count * (count - 1L) count (count - 1L) count 1L 2 System.out.println(pairs) System.out.println System.out System System.out pairs String [] args args public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    }
} public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    }
} 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 scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Long> counts = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            String s = scanner.next();
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            s = new String(tmp);
            long count = counts.getOrDefault(s, 0L);
            counts.put(s, count + 1L);
        }
        long pairs = 0;
        for (long count : counts.values()) {
            pairs += (count * (count - 1L) / 2);
        }
        System.out.println(pairs);
    }
}