


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() long res = 0; res 0 for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        } {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        } String s = sc.next(); s sc.next() sc.next sc char[] ch = s.toCharArray(); ch s.toCharArray() s.toCharArray s Arrays.sort(ch) Arrays.sort Arrays ch String s2 = new String(ch); s2 new String(ch) if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            } map.containsKey(s2) map.containsKey map s2 {
                map.put(s2, map.get(s2)+1);
            } map.put(s2, map.get(s2)+1) map.put map s2 map.get(s2)+1 map.get(s2) map.get map s2 1 {
                map.put(s2, 1);
            } map.put(s2, 1) map.put map s2 1 for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        } Map.Entry<String,Integer> entry map.entrySet() map.entrySet map {
            long l = entry.getValue();
            res += l*(l-1)/2;
        } {
            long l = entry.getValue();
            res += l*(l-1)/2;
        } long l = entry.getValue(); l entry.getValue() entry.getValue entry res += l*(l-1)/2 res l*(l-1)/2 l*(l-1) l (l-1) l 1 2 System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    }
} Main



import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        long res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            char[] ch = s.toCharArray();
            Arrays.sort(ch);
            String s2 = new String(ch);
            if(map.containsKey(s2)) {
                map.put(s2, map.get(s2)+1);
            } else {
                map.put(s2, 1);
            }
        }
        for(Map.Entry<String,Integer> entry : map.entrySet()) {
            long l = entry.getValue();
            res += l*(l-1)/2;
        }
        System.out.println(res);
    }
}
