import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
} import java.util.*; util.* java import java.util.Map.Entry; Entry java.util.Map public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    } main {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) Integer N = scan.nextInt(); N scan.nextInt() scan.nextInt scan long count = 0; count 0 HashMap<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        } {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        } String s = scan.next(); s scan.next() scan.next scan char[] sArray = s.toCharArray(); sArray s.toCharArray() s.toCharArray s Arrays.sort(sArray) Arrays.sort Arrays sArray String sorted = new String(sArray); sorted new String(sArray) if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1); map.containsKey(sorted) map.containsKey map sorted map.put(sorted, map.get(sorted) + 1) map.put map sorted map.get(sorted) + 1 map.get(sorted) map.get map sorted 1 map.put(sorted, (long)1) map.put map sorted (long)1 for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        } Entry<String, Long> entry map.entrySet() map.entrySet map {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        } {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        } long value = entry.getValue(); value entry.getValue() entry.getValue entry count += value * (value - 1) / 2 count value * (value - 1) / 2 value * (value - 1) value (value - 1) value 1 2 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
} Main
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        long count = 0;
        HashMap<String, Long> map = new HashMap<String, Long>(); 
        for(int i = 0; i < N; i++) {
            String s = scan.next();
            char[] sArray = s.toCharArray();
            Arrays.sort(sArray);
            String sorted = new String(sArray);
            if(map.containsKey(sorted))
                map.put(sorted, map.get(sorted) + 1);
            else
                map.put(sorted, (long)1);
        }
        for(Entry<String, Long> entry : map.entrySet()) {
            long value = entry.getValue();
            count += value * (value - 1) / 2;
        }
        System.out.println(count);
        
    }
}
