import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

    }
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
    public static boolean debug = true;

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        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 HashMap<String,Long> map = new HashMap<>(); map new HashMap<>() for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        } int i=0; int i=0; i 0 i< n i n i++ i++ i {
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        } {
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        } char[] array = sc.next().toCharArray(); array sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(array) Arrays.sort Arrays array String result = new String(array); result new String(array) long temp =0; temp 0 if(map.containsKey(result)){
                temp = map.get(result);
            } map.containsKey(result) map.containsKey map result {
                temp = map.get(result);
            } temp = map.get(result) temp map.get(result) map.get map result map.put(result,temp+1) map.put map result temp+1 temp 1 long count =0; count 0 for(long c:map.values()){
            count += c * (c-1) / 2;
        } long c map.values() map.values map {
            count += c * (c-1) / 2;
        } {
            count += c * (c-1) / 2;
        } count += c * (c-1) / 2 count c * (c-1) / 2 c * (c-1) c (c-1) c 1 2 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static boolean debug = true;

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

    }
} public class Main {
    public static boolean debug = true;

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

    }
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

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

        HashMap<String,Long> map = new HashMap<>();
        for(int i=0; i< n;i++){
            char[] array = sc.next().toCharArray();
            Arrays.sort(array);

            String result = new String(array);

            long temp =0;
            if(map.containsKey(result)){
                temp = map.get(result);
            }
            map.put(result,temp+1);

        }

        long count =0;
        for(long c:map.values()){
            count += c * (c-1) / 2;
        }
        System.out.println(count);

    }
}