import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.LinkedHashMap; LinkedHashMap java.util import java.util.Map; Map java.util public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    }

} Main public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    } main {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) final int N = Integer.parseInt(reader.readLine()); N Integer.parseInt(reader.readLine()) Integer.parseInt Integer reader.readLine() reader.readLine reader Map<String, Integer> map = new LinkedHashMap<>(); map new LinkedHashMap<>() Long count = (long) 0; count (long) 0 for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        } {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        } String str = reader.readLine(); str reader.readLine() reader.readLine reader char[] chars = str.toCharArray(); chars str.toCharArray() str.toCharArray str Arrays.parallelSort(chars) Arrays.parallelSort Arrays chars str = new String(chars) str new String(chars) if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            } map.containsKey(str) map.containsKey map str {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } count += map.get(str) count map.get(str) map.get map str map.put(str, map.get(str) + 1) map.put map str map.get(str) + 1 map.get(str) map.get map str 1 {
                map.put(str, 1);
            } map.put(str, 1) map.put map str 1 System.out.println(count) System.out.println System.out System System.out count reader.close() reader.close reader String[] args args public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    }

} public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int N = Integer.parseInt(reader.readLine());
        Map<String, Integer> map = new LinkedHashMap<>();
        Long count = (long) 0;
        for (int i = 0; i < N; i++) {
            String str = reader.readLine();
            char[] chars = str.toCharArray();
            Arrays.parallelSort(chars);
            str = new String(chars);
            if (map.containsKey(str)) {
                count += map.get(str);
                map.put(str, map.get(str) + 1);
            } else {
                map.put(str, 1);
            }
        }
        System.out.println(count);
        reader.close();

    }

}
