import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    } main {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    } BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); stdin new BufferedReader(new InputStreamReader(System.in)) Long count = new Long(0); count new Long(0) Integer n = Integer.parseInt(stdin.readLine()); n Integer.parseInt(stdin.readLine()) Integer.parseInt Integer stdin.readLine() stdin.readLine stdin Map<String, Integer> map = new HashMap<>(); map new HashMap<>() String line; line while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        } (line = stdin.readLine()) != null (line = stdin.readLine()) line stdin.readLine() stdin.readLine stdin null {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        } char[] chars = line.toCharArray(); chars line.toCharArray() line.toCharArray line Arrays.sort(chars) Arrays.sort Arrays chars String newStr = new String(chars); newStr new String(chars) Integer temp = map.get(newStr); temp map.get(newStr) map.get map newStr if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            } temp == null temp null {
                map.put(newStr, 1);
            } map.put(newStr, 1) map.put map newStr 1 {
                count += temp;
                map.put(newStr, temp+1);
            } count += temp count temp map.put(newStr, temp+1) map.put map newStr temp+1 temp 1 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) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
} Main
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        Long count = new Long(0);

        Integer n = Integer.parseInt(stdin.readLine());
        
        Map<String, Integer> map = new HashMap<>();
        
        // 標準入力を1行ずつ読み出す。
        String line;
        while ((line = stdin.readLine()) != null) {
            char[] chars = line.toCharArray();
            Arrays.sort(chars);
            String newStr = new String(chars);
            Integer temp = map.get(newStr);
            if (temp == null) {
                map.put(newStr, 1);
            } else {
                count += temp;
                map.put(newStr, temp+1);
            }
        }
        System.out.println(count);
    }
}