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

class Main {

    public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String, Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {

    public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String, Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
} Main public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String, Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    } main {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String, Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    } MyScanner sc = new MyScanner(); sc new MyScanner() int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Map<String, Long> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       } int i=0; int i=0; i 0 i<N i N i++ i++ i {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       } {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       } char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(s) Arrays.sort Arrays s String key = String.valueOf(s); key String.valueOf(s) String.valueOf String s if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           } map.get(key) != null map.get(key) map.get map key null {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           } ans += map.get(key) ans map.get(key) map.get map key map.put(key, map.get(key) + 1) map.put map key map.get(key) + 1 map.get(key) map.get map key 1 {
               map.put(key, 1L);
           } map.put(key, 1L) map.put map key 1L System.out.println(ans) System.out.println System.out System System.out ans String[] args args static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    } MyScanner BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15); reader new BufferedReader(new InputStreamReader(System.in), 1 << 15) StringTokenizer tokenizer; tokenizer String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        } next {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        } try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            } catch (IOException ignored) {
            } IOException ignored {
            } {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int N = sc.nextInt();
       Map<String, Long> map = new HashMap<>();
       long ans = 0;
       for (int i=0; i<N; i++) {
           char[] s = sc.next().toCharArray();
           Arrays.sort(s);
           String key = String.valueOf(s);
           if (map.get(key) != null) {
               ans += map.get(key);
               map.put(key, map.get(key) + 1);     
           }
           else {
               map.put(key, 1L);
           }
       }
       System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}