import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.util.HashMap; HashMap java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) Task solver = new Task(); solver new Task() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    } Task public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        } solve {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        } int n = in.nextInt(); n in.nextInt() in.nextInt in long res = 0; res 0 HashMap<String, Integer> hm = new HashMap<String, Integer>(); hm new HashMap<String, Integer>() for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            } {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            } String s = in.next(); s in.next() in.next in char[] ca = s.toCharArray(); ca s.toCharArray() s.toCharArray s Arrays.sort(ca) Arrays.sort Arrays ca String _s = new String(ca); _s new String(ca) if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                } hm.containsKey(_s) hm.containsKey hm _s {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } hm.replace(_s, hm.get(_s) + 1) hm.replace hm _s hm.get(_s) + 1 hm.get(_s) hm.get hm _s 1 res += hm.get(_s) res hm.get(_s) hm.get hm _s {
                    hm.put(_s, 0);
                } hm.put(_s, 0) hm.put hm _s 0 out.println(res) out.println out res int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long res = 0;
            HashMap<String, Integer> hm = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                char[] ca = s.toCharArray();
                Arrays.sort(ca);
                String _s = new String(ca);
                if (hm.containsKey(_s)) {
                    hm.replace(_s, hm.get(_s) + 1);
                    res += hm.get(_s);
                } else {
                    hm.put(_s, 0);
                }
            }
            out.println(res);
        }

    }
}

