import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc ArrayList<String> s = new ArrayList<>(); s new ArrayList<>() HashMap<String, Long> strMap = new HashMap<>(); strMap new HashMap<>() long ans = 0; ans 0 for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        } {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        } String[] temp = sc.nextLine().split(""); temp sc.nextLine().split("") sc.nextLine().split sc.nextLine() sc.nextLine sc "" Arrays.sort(temp) Arrays.sort Arrays temp s.add(String.join("", temp)) s.add s String.join("", temp) String.join String "" temp if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            } strMap.containsKey(s.get(i)) strMap.containsKey strMap s.get(i) s.get s i {
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } strMap.put(s.get(i), strMap.get(s.get(i)) + 1) strMap.put strMap s.get(i) s.get s i strMap.get(s.get(i)) + 1 strMap.get(s.get(i)) strMap.get strMap s.get(i) s.get s i 1 {
                strMap.put(s.get(i), Long.parseLong("1"));
            } strMap.put(s.get(i), Long.parseLong("1")) strMap.put strMap s.get(i) s.get s i Long.parseLong("1") Long.parseLong Long "1" for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        } String key strMap.keySet() strMap.keySet strMap {
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        } {
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        } long l = strMap.get(key); l strMap.get(key) strMap.get strMap key ans += l * (l - 1) / 2 ans l * (l - 1) / 2 l * (l - 1) l (l - 1) l 1 2 System.out.println(ans) System.out.println System.out System System.out ans return; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    }
}
