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 = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -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);
        int N = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -1) /2;
        }

        System.out.println(ans);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -1) /2;
        }

        System.out.println(ans);

    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -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 Map<String,Integer> countMap = new HashMap<>(); countMap new HashMap<>() for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+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 str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        } {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+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 str = new String(chars); str new String(chars) if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            } !countMap.containsKey(str) countMap.containsKey(str) countMap.containsKey countMap str {
                countMap.put(str,1);
            } countMap.put(str,1) countMap.put countMap str 1 {
                countMap.put(str,countMap.get(str)+1);
            } countMap.put(str,countMap.get(str)+1) countMap.put countMap str countMap.get(str)+1 countMap.get(str) countMap.get countMap str 1 long ans = 0 ; ans 0 for (int count: countMap.values()) {
            ans += (long) count * (count -1) /2;
        } int count countMap.values() countMap.values countMap {
            ans += (long) count * (count -1) /2;
        } {
            ans += (long) count * (count -1) /2;
        } ans += (long) count * (count -1) /2 ans (long) count * (count -1) /2 (long) count * (count -1) (long) count (count -1) count 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();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -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();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -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);
        int N = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -1) /2;
        }

        System.out.println(ans);

    }
}
