import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
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<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap 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) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    } 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<>() String[] s = new String[n]; s new String[n] n for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            s[i] = sc.next();
        } {
            s[i] = sc.next();
        } s[i] = sc.next() s[i] s i sc.next() sc.next sc long cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        } {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        } char[] c = s[i].toCharArray(); c s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(c) Arrays.sort Arrays c String str = new String(c); str new String(c) if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            } !map.containsKey(str) map.containsKey(str) map.containsKey map str {
                map.put(str, 1);
            } map.put(str, 1) map.put map str 1 {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            } int cmb = map.get(str); cmb map.get(str) map.get map str cnt += cmb cnt cmb map.put(str, cmb + 1) map.put map str cmb + 1 cmb 1 System.out.println(cnt) System.out.println System.out System System.out cnt 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<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
} 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<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
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<>();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
 
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            char[] c = s[i].toCharArray();
            Arrays.sort(c);
            String str = new String(c);
            if (!map.containsKey(str)) {
                map.put(str, 1);
            } else {
                int cmb = map.get(str);
                cnt += cmb;
                map.put(str, cmb + 1);
            }
        }
        System.out.println(cnt);
    }
 
}