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