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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(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 void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc HashMap<String,Long> map =  new HashMap<>(); map new HashMap<>() for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        } {
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        } String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c s = new String(c) s new String(c) Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1); cnt (map.containsKey(s) ? map.get(s) + 1 : 1) map.containsKey(s) map.containsKey map s map.get(s) + 1 map.get(s) map.get map s 1 1 map.put(s, cnt) map.put map s cnt long count = 0; count 0 for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        } Long l map.values() map.values map {
            count = count + (l * (l -1) / 2);
        } {
            count = count + (l * (l -1) / 2);
        } count = count + (l * (l -1) / 2) count count + (l * (l -1) / 2) count (l * (l -1) / 2) l * (l -1) l (l -1) l 1 2 System.out.print(count) System.out.print 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 a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    }
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            Long cnt = (map.containsKey(s) ? map.get(s) + 1 : 1);
			map.put(s, cnt);
        }

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