import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] s = new String[n]; s new String[n] n long count = 0; count 0 for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        } {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        } s[i] = sc.next() s[i] s i sc.next() sc.next sc char[] c = s[i].toCharArray(); c s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(c) Arrays.sort Arrays c s[i] = "" s[i] s i "" for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            } int j = 0; int j = 0; j 0 j < c.length j c.length c c.length j++ j++ j {
                s[i] += String.valueOf(c[j]);
            } {
                s[i] += String.valueOf(c[j]);
            } s[i] += String.valueOf(c[j]) s[i] s i String.valueOf(c[j]) String.valueOf String c[j] c j Arrays.sort(s) Arrays.sort Arrays s Map<String, Long> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        } {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        } if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            } map.containsKey(s[i]) map.containsKey map s[i] s i {
                map.put(s[i], map.get(s[i]) + 1);
            } map.put(s[i], map.get(s[i]) + 1) map.put map s[i] s i map.get(s[i]) + 1 map.get(s[i]) map.get map s[i] s i 1 {
                map.put(s[i], (long) 1);
            } map.put(s[i], (long) 1) map.put map s[i] s i (long) 1 for (long i : map.values()) {
            count += i * (i - 1) / 2;
        } long i map.values() map.values map {
            count += i * (i - 1) / 2;
        } {
            count += i * (i - 1) / 2;
        } count += i * (i - 1) / 2 count i * (i - 1) / 2 i * (i - 1) i (i - 1) i 1 2 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            s[i] = "";
            for (int j = 0; j < c.length; j++) {
                s[i] += String.valueOf(c[j]);
            }
        }
        Arrays.sort(s);
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], (long) 1);
            }
        }
        for (long i : map.values()) {
            count += i * (i - 1) / 2;
        }
        System.out.println(count);
    }
}
