import java.util.*;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

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

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

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

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc HashMap<String, Integer> s = new HashMap<>(); s new HashMap<>() long result = 0; result 0 for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        } {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        } String[] arrS = sc.next().split(""); arrS sc.next().split("") sc.next().split sc.next() sc.next sc "" Arrays.sort(arrS) Arrays.sort Arrays arrS StringBuilder sb = new StringBuilder(); sb new StringBuilder() for (String c : arrS) {
                sb.append(c);
            } String c arrS {
                sb.append(c);
            } {
                sb.append(c);
            } sb.append(c) sb.append sb c String key = sb.toString(); key sb.toString() sb.toString sb if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            } s.containsKey(key) s.containsKey s key {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } result += s.get(key) result s.get(key) s.get s key s.put(key, s.get(key) + 1) s.put s key s.get(key) + 1 s.get(key) s.get s key 1 {
                s.put(key, 1);
            } s.put(key, 1) s.put s key 1 System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

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

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

        System.out.println(result);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<String, Integer> s = new HashMap<>();

        long result = 0;
        for (int i = 0; i < n; i++) {
            String[] arrS = sc.next().split("");
            Arrays.sort(arrS);
            StringBuilder sb = new StringBuilder();
            for (String c : arrS) {
                sb.append(c);
            }
            String key = sb.toString();
            if (s.containsKey(key)) {
                result += s.get(key);
                s.put(key, s.get(key) + 1);
            } else {
                s.put(key, 1);
            }
        }

        System.out.println(result);
    }
}