import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io 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 public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    }
} Main public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    } main {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    } InputStreamReader is = new InputStreamReader(System.in); is new InputStreamReader(System.in) BufferedReader reader = new BufferedReader(is); reader new BufferedReader(is) List<String> mylist = new ArrayList<>(); mylist new ArrayList<>() String strinput = reader.readLine(); strinput reader.readLine() reader.readLine reader while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        } strinput != null strinput null {

            mylist.add(strinput);
            strinput = reader.readLine();

        } mylist.add(strinput) mylist.add mylist strinput strinput = reader.readLine() strinput reader.readLine() reader.readLine reader String arr01[] = mylist.get(0).split(" "); arr01 mylist.get(0).split(" ") mylist.get(0).split mylist.get(0) mylist.get mylist 0 " " Integer n = Integer.valueOf(arr01[0]); n Integer.valueOf(arr01[0]) Integer.valueOf Integer arr01[0] arr01 0 List<String> list = new ArrayList<>(); list new ArrayList<>() for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        } int i = 1; int i = 1; i 1 i < 1 + n i 1 + n 1 n i++ i++ i {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        } {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        } String temp = mylist.get(i); temp mylist.get(i) mylist.get mylist i char[] c = temp.toCharArray(); c temp.toCharArray() temp.toCharArray temp Arrays.sort(c) Arrays.sort Arrays c String str1 = new String(c); str1 new String(c) list.add(str1) list.add list str1 HashMap<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        } int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        } {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        } if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            } map.containsKey(list.get(i)) map.containsKey map list.get(i) list.get list i {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } int val = map.get(list.get(i)); val map.get(list.get(i)) map.get map list.get(i) list.get list i map.put(list.get(i), val + 1) map.put map list.get(i) list.get list i val + 1 val 1 {
                map.put(list.get(i), 1);
            } map.put(list.get(i), 1) map.put map list.get(i) list.get list i 1 long mysum = 0; mysum 0 for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        } Integer v map.values() map.values map {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        } {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        } long ans_temp = (long) v * (v - 1); ans_temp (long) v * (v - 1) (long) v (v - 1) v 1 mysum += ans_temp / 2 mysum ans_temp / 2 ans_temp 2 System.out.println(mysum) System.out.println System.out System System.out mysum String[] args args public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    }
} public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Integer n = Integer.valueOf(arr01[0]);

        List<String> list = new ArrayList<>();
        for (int i = 1; i < 1 + n; i++) {
            String temp = mylist.get(i);

            char[] c = temp.toCharArray();
            Arrays.sort(c);
            String str1 = new String(c);
            list.add(str1);

        }

        //昇順でソート
        //        Collections.sort(list);

        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for (int i = 0; i < list.size(); i++) {

            if (map.containsKey(list.get(i))) {
                int val = map.get(list.get(i));
                map.put(list.get(i), val + 1);
            } else {
                map.put(list.get(i), 1);
            }

        }

        long mysum = 0;
        for (Integer v : map.values()) {
            long ans_temp = (long) v * (v - 1);
            mysum += ans_temp / 2;
        }

        System.out.println(mysum);

    }
}
