import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    } main {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc List<String> list = new ArrayList<String>(); list new ArrayList<String>() for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        } long i = 0; long i = 0; i 0 i < n i n i++ i++ i {
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        } {
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        } String s = sc.next(); s sc.next() sc.next sc char temp[] = s.toCharArray(); temp s.toCharArray() s.toCharArray s Arrays.sort(temp) Arrays.sort Arrays temp list.add(new String(temp)) list.add list new String(temp) Collections.sort(list) Collections.sort Collections list Map<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        } String s list {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        } {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        } if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            } map.containsKey(s) map.containsKey map s {
                map.put(s, (map.get(s)+1));
            } map.put(s, (map.get(s)+1)) map.put map s (map.get(s)+1) map.get(s) map.get map s 1 {
                map.put(s, 1L);
            } map.put(s, 1L) map.put map s 1L long sum = 0; sum 0 for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        } long c map.values() map.values map {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        } {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        } for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            } long i = c - 1; long i = c - 1; i c - 1 c 1 i > 0 i 0 i-- i-- i {
                sum += i;
                // System.out.println("sum="+sum);
            } {
                sum += i;
                // System.out.println("sum="+sum);
            } sum += i sum i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        List<String> list = new ArrayList<String>();
        for(long i = 0; i < n; i++){
            String s = sc.next();
            char temp[] = s.toCharArray();
            Arrays.sort(temp);
            list.add(new String(temp));
        }
        Collections.sort(list);


        Map<String, Long> map = new HashMap<String, Long>();
        for(String s : list) {
            if(map.containsKey(s)) {
                map.put(s, (map.get(s)+1));
            } else {
                map.put(s, 1L);
            }
        }

        long sum = 0;
        for(long c : map.values()) {
            // System.out.println("c="+c);
            for(long i = c - 1; i > 0; i--) {
                sum += i;
                // System.out.println("sum="+sum);
            }
        }

        // System.out.println(map.toString());
        System.out.println(sum);

    }
}
