import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

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

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

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

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long count = 0; count 0 HashMap<String, Integer> hash = new HashMap<>(); hash new HashMap<>() for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        } {
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        } char[] charArray = sc.next().toCharArray(); charArray sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(charArray) Arrays.sort Arrays charArray String str = String.valueOf(charArray); str String.valueOf(charArray) String.valueOf String charArray if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            } hash.containsKey(str) hash.containsKey hash str {
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } hash.put(str, hash.get(str) + 1) hash.put hash str hash.get(str) + 1 hash.get(str) hash.get hash str 1 count += hash.get(str) count hash.get(str) hash.get hash str {
                hash.put(str, 0);
            } hash.put(str, 0) hash.put hash str 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

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

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

        System.out.println(count);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

        System.out.println(count);
    }
}