import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    }

    static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    }

    static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        } {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        } String s = sc.next(); s sc.next() sc.next sc s = str_sort(s) s str_sort(s) str_sort s if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            } map.get(s) == null map.get(s) map.get map s null {
                map.put(s, 1);
            } map.put(s, 1) map.put map s 1 {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            } int val = map.get(s); val map.get(s) map.get map s ans += val ans val map.replace(s, val+1) map.replace map s val+1 val 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    } str_sort {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    } char[] re = a.toCharArray(); re a.toCharArray() a.toCharArray a for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        } int i = 0; int i = 0; i 0 i < re.length-1 i re.length-1 re.length re re.length 1 i++ i++ i {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        } {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        } for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            } int j = i+1; int j = i+1; j i+1 i 1 j < re.length j re.length re re.length j++ j++ j {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            } {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            } if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                } re[i] > re[j] re[i] re i re[j] re j {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                } char tmp = re[j]; tmp re[j] re j re[j] = re[i] re[j] re j re[i] re i re[i] = tmp re[i] re i tmp return new String(re); new String(re) String a a public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    }

    static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    }

    static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            s = str_sort(s);

            if (map.get(s) == null) {
                map.put(s, 1);
            } else {
                int val = map.get(s);
                ans += val;
                map.replace(s, val+1);
            }
        }

        System.out.println(ans);
    }

    static String str_sort(String a) {
        char[] re = a.toCharArray();

        for (int i = 0; i < re.length-1; i++) {
            for (int j = i+1; j < re.length; j++) {
                if (re[i] > re[j]) {
                    char tmp = re[j];
                    re[j] = re[i];
                    re[i] = tmp;
                }
            }
        }

        return new String(re);
    }
}