import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        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 long ans = 0; ans 0 HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        } {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        } char[] chars = sc.next().toCharArray(); chars sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(chars) Arrays.sort Arrays chars String s = new String(chars); s new String(chars) Integer cnt = map.get(s); cnt map.get(s) map.get map s if (cnt == null) {
                cnt = 0;
            } cnt == null cnt null {
                cnt = 0;
            } cnt = 0 cnt 0 map.put(s, cnt + 1) map.put map s cnt + 1 cnt 1 for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        } long num map.values() map.values map {
            ans += num * (num - 1) / 2;
        } {
            ans += num * (num - 1) / 2;
        } ans += num * (num - 1) / 2 ans num * (num - 1) / 2 num * (num - 1) num (num - 1) num 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
} Main
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            Arrays.sort(chars);
            String s = new String(chars);
            Integer cnt = map.get(s);
            if (cnt == null) {
                cnt = 0;
            }
            map.put(s, cnt + 1);
        }
        for (long num : map.values()) {
            ans += num * (num - 1) / 2;
        }
        System.out.println(ans);
    }
}