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 = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    }
} 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 = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long res = 0; res 0 Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        } {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        } char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String s = String.valueOf(c); s String.valueOf(c) String.valueOf String c int tmp = map.getOrDefault(s, 0); tmp map.getOrDefault(s, 0) map.getOrDefault map s 0 res += tmp res tmp map.put(s, tmp + 1) map.put map s tmp + 1 tmp 1 System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    }
} 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 = Integer.parseInt(sc.next());
        long res = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            int tmp = map.getOrDefault(s, 0);
            res += tmp;
            map.put(s, tmp + 1);
        }

        System.out.println(res);
    }
}
