import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.List; List java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    } main {
        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = Integer.parseInt(scan.next()); N Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan List<String> targets = new ArrayList<>(); targets new ArrayList<>() for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            targets.add(scan.next());
        } {
            targets.add(scan.next());
        } targets.add(scan.next()) targets.add targets scan.next() scan.next scan scan.close() scan.close scan Map<String, Long> tmp = new HashMap<String, Long>(); tmp new HashMap<String, Long>() for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        } String target targets {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        } {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        } char[] c = target.toCharArray(); c target.toCharArray() target.toCharArray target Arrays.sort(c) Arrays.sort Arrays c String sortTarget = new String(c); sortTarget new String(c) if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            } tmp.containsKey(sortTarget) tmp.containsKey tmp sortTarget {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } tmp.put(sortTarget, tmp.get(sortTarget) + 1) tmp.put tmp sortTarget tmp.get(sortTarget) + 1 tmp.get(sortTarget) tmp.get tmp sortTarget 1 {
                tmp.put(sortTarget, 0L);
            } tmp.put(sortTarget, 0L) tmp.put tmp sortTarget 0L long result = 0; result 0 for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        } Long l tmp.values() tmp.values tmp {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        } {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        } for (long t = 1; t < l + 1; t++) {
                result += t;
            } long t = 1; long t = 1; t 1 t < l + 1 t l + 1 l 1 t++ t++ t {
                result += t;
            } {
                result += t;
            } result += t result t System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    }
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

        int N = Integer.parseInt(scan.next()); 
        List<String> targets = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            targets.add(scan.next());
        }
        scan.close();

        Map<String, Long> tmp = new HashMap<String, Long>();
        for (String target : targets) {
            char[] c = target.toCharArray();
            Arrays.sort(c);
            String sortTarget = new String(c);
            if (tmp.containsKey(sortTarget)) {
                tmp.put(sortTarget, tmp.get(sortTarget) + 1);
            } else {
                tmp.put(sortTarget, 0L);
            }
        }
        
        long result = 0;
        for (Long l : tmp.values()) {
            for (long t = 1; t < l + 1; t++) {
                result += t;
            }
        }

        System.out.println(result);
    }
}