import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}
 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.HashMap; HashMap java.util import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util import java.util.Map; Map java.util import java.util.Map.Entry; Entry java.util.Map import java.io.BufferedReader; BufferedReader java.io import java.io.InputStream; InputStream java.io public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        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 MyScanner in = new MyScanner(inputStream); in new MyScanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) C solver = new C(); solver new C() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    } C public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        } solve {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        } int N = in.nextInt(); N in.nextInt() in.nextInt in Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            } {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            } String s = in.next(); s in.next() in.next in char[] cs = s.toCharArray(); cs s.toCharArray() s.toCharArray s Arrays.sort(cs) Arrays.sort Arrays cs s = new String(cs) s new String(cs) map.put(s, map.getOrDefault(s, 0) + 1) map.put map s map.getOrDefault(s, 0) + 1 map.getOrDefault(s, 0) map.getOrDefault map s 0 1 long sum = 0; sum 0 for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            } Map.Entry<String, Integer> entry map.entrySet() map.entrySet map {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            } {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            } long value = entry.getValue(); value entry.getValue() entry.getValue entry if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                } value > 1 value 1 {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                } long temp = 0; temp 0 for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    } long i = 2; long i = 2; i 2 i <= value i value i++ i++ i {
                        temp += i - 1;
                    } {
                        temp += i - 1;
                    } temp += i - 1 temp i - 1 i 1 sum += temp sum temp out.println(sum) out.println out sum int testNumber testNumber MyScanner in in PrintWriter out out static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    } MyScanner private BufferedReader in; in private StringTokenizer st; st public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        } MyScanner {
            in = new BufferedReader(new InputStreamReader(stream));
        } in = new BufferedReader(new InputStreamReader(stream)) in new BufferedReader(new InputStreamReader(stream)) InputStream stream stream public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } String rl = in.readLine(); rl in.readLine() in.readLine in if (rl == null) {
                        return null;
                    } rl == null rl null {
                        return null;
                    } return null; null st = new StringTokenizer(rl) st new StringTokenizer(rl) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String s = in.next();
                char[] cs = s.toCharArray();
                Arrays.sort(cs);
                s = new String(cs);
                map.put(s, map.getOrDefault(s, 0) + 1);
            }

            long sum = 0;
            for (Map.Entry<String, Integer> entry : map.entrySet()) {
                long value = entry.getValue();
                if (value > 1) {
                    long temp = 0;
                    for (long i = 2; i <= value; i++) {
                        temp += i - 1;
                    }
                    sum += temp;
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

