import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
} import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.HashMap; HashMap java.util import java.util.Iterator; Iterator java.util import java.util.List; List 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 std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    } main {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    } Scanner std = new Scanner(System.in); std new Scanner(System.in) int n = std.nextInt(); n std.nextInt() std.nextInt std String[] texts = new String[n]; texts new String[n] n for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            texts[i] = std.next();
        } {
            texts[i] = std.next();
        } texts[i] = std.next() texts[i] texts i std.next() std.next std String[] sortedTexts = new String[n]; sortedTexts new String[n] n for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        } {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        } String text = texts[i]; text texts[i] texts i List<String> textList = Arrays.asList(text.split("")); textList Arrays.asList(text.split("")) Arrays.asList Arrays text.split("") text.split text "" Collections.sort(textList) Collections.sort Collections textList String sorted = String.join("",textList); sorted String.join("",textList) String.join String "" textList sortedTexts[i] = sorted sortedTexts[i] sortedTexts i sorted Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        } {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        } String s = sortedTexts[i]; s sortedTexts[i] sortedTexts i map.put(s, map.getOrDefault(s, 0) + 1) map.put map s map.getOrDefault(s, 0) + 1 map.getOrDefault(s, 0) map.getOrDefault map s 0 1 Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator(); it map.entrySet().iterator() map.entrySet().iterator map.entrySet() map.entrySet map long ans = 0; ans 0 while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        } it.hasNext() it.hasNext it {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        } long count = it.next().getValue(); count it.next().getValue() it.next().getValue it.next() it.next it ans += count * (count - 1) / 2 ans count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 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 std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
} Main
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
}
