import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner String[] stringList = new String[n]; stringList new String[n] n for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            stringList[i] = scanner.next();
        } {
            stringList[i] = scanner.next();
        } stringList[i] = scanner.next() stringList[i] stringList i scanner.next() scanner.next scanner long count = 0; count 0 Map<String, Long> hashMap = new HashMap<>(); hashMap new HashMap<>() for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        } {
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        } char[] c = stringList[i].toCharArray(); c stringList[i].toCharArray() stringList[i].toCharArray stringList[i] stringList i Arrays.sort(c) Arrays.sort Arrays c String str = String.valueOf(c); str String.valueOf(c) String.valueOf String c if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            } hashMap.containsKey(str) hashMap.containsKey hashMap str {
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            } long num = hashMap.get(str); num hashMap.get(str) hashMap.get hashMap str count += num count num hashMap.put(str,num+1) hashMap.put hashMap str num+1 num 1 {
                hashMap.put(str,1l);
            } hashMap.put(str,1l) hashMap.put hashMap str 1l 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) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] stringList = new String[n];
        for (int i=0;i<n;i++){
            stringList[i] = scanner.next();
        }
        long count = 0;

        Map<String, Long> hashMap = new HashMap<>();
        for (int i=0;i<n;i++){
            char[] c = stringList[i].toCharArray();
            Arrays.sort(c);
            String str = String.valueOf(c);
            if (hashMap.containsKey(str)){
                long num = hashMap.get(str);
                count += num;
                hashMap.put(str,num+1);
            }else {
                hashMap.put(str,1l);
            }
        }
        System.out.println(count);
    }
}
