import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
} Main private static final int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    } main {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = in.nextInt(); n in.nextInt() in.nextInt in Map<String, ArrayList<Integer>> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        } {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        } char[] c = in.next().toCharArray(); c in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(c) Arrays.sort Arrays c String s = new String(c); s new String(c) if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            } !map.containsKey(s) map.containsKey(s) map.containsKey map s {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            } ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() list.add(i) list.add list i map.put(s, list) map.put map s list {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            } ArrayList<Integer> list = map.get(s); list map.get(s) map.get map s list.add(i) list.add list i long ans = 0; ans 0 Set<String> keySet = map.keySet(); keySet map.keySet() map.keySet map for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        } String t keySet {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        } {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        } ArrayList<Integer> list = map.get(t); list map.get(t) map.get map t int m = list.size(); m list.size() list.size list ans += (long)(m - 1) * m / 2 ans (long)(m - 1) * m / 2 (long)(m - 1) * m (long)(m - 1) m 1 m 2 out.println(ans) out.println out ans out.close() out.close out String[] args args public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
} public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
} Main
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
}
