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);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    }
} 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);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long ans = 0; ans 0 int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Map<String, Long> map = new HashMap<>(); map new HashMap<>() for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        } {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        } char[] ca = sc.next().toCharArray(); ca sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(ca) Arrays.sort Arrays ca String s = String.valueOf(ca); s String.valueOf(ca) String.valueOf String ca if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L); map.containsKey(s) map.containsKey map s map.put(s, map.get(s) + 1) map.put map s map.get(s) + 1 map.get(s) map.get map s 1 map.put(s, 1L) map.put map s 1L for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        } String key map.keySet() map.keySet map {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        } {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        } ans += map.get(key) * (map.get(key) - 1) / 2 ans map.get(key) * (map.get(key) - 1) / 2 map.get(key) * (map.get(key) - 1) map.get(key) map.get map key (map.get(key) - 1) map.get(key) map.get map key 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);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    }
} 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);
        long ans = 0;
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            String s = String.valueOf(ca);
            if(map.containsKey(s)) map.put(s, map.get(s) + 1);
            else map.put(s, 1L);
        }
        for(String key : map.keySet()) {
            ans += map.get(key) * (map.get(key) - 1) / 2;
        }
        System.out.println(ans);
    }
}
