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
 */
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);
        GreenBin solver = new GreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    }
}
 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);
        GreenBin solver = new GreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    }
} 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);
        GreenBin solver = new GreenBin();
        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);
        GreenBin solver = new GreenBin();
        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) GreenBin solver = new GreenBin(); solver new GreenBin() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    } GreenBin public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        } solve {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        } int n = in.nextInt(); n in.nextInt() in.nextInt in HashMap<String, Integer> set = new HashMap<>(); set new HashMap<>() for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            } {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            } char[] chars = in.next().toCharArray(); chars in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(chars) Arrays.sort Arrays chars StringBuilder sb = new StringBuilder(); sb new StringBuilder() sb.append(chars) sb.append sb chars set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1) set.put set Arrays.toString(chars) Arrays.toString Arrays chars set.getOrDefault(Arrays.toString(chars), 0) + 1 set.getOrDefault(Arrays.toString(chars), 0) set.getOrDefault set Arrays.toString(chars) Arrays.toString Arrays chars 0 1 long result = 0; result 0 for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            } String key set.keySet() set.keySet set {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            } {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            } int a = set.get(key); a set.get(key) set.get set key result += (long) a * (a - 1) / 2 result (long) a * (a - 1) / 2 (long) a * (a - 1) (long) a (a - 1) a 1 2 out.println(result) out.println out result 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);
        GreenBin solver = new GreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    }
} 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);
        GreenBin solver = new GreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    }
} 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
 */
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);
        GreenBin solver = new GreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class GreenBin {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> set = new HashMap<>();
            for (int i = 0; i < n; i++) {
                char[] chars = in.next().toCharArray();
                Arrays.sort(chars);
                StringBuilder sb = new StringBuilder();
                sb.append(chars);
                set.put(Arrays.toString(chars), set.getOrDefault(Arrays.toString(chars), 0) + 1);
            }

            long result = 0;
            for (String key : set.keySet()) {
                int a = set.get(key);
                result += (long) a * (a - 1) / 2;
            }
            out.println(result);
        }

    }
}

