import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    }
}
 import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner long ans = 0; ans 0 HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        } {
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        } String s = scanner.next(); s scanner.next() scanner.next scanner char sa[] = s.toCharArray(); sa s.toCharArray() s.toCharArray s Arrays.sort(sa) Arrays.sort Arrays sa String sorted = new String(sa); sorted new String(sa) ans += map.getOrDefault(sorted, 0) ans map.getOrDefault(sorted, 0) map.getOrDefault map sorted 0 map.put(sorted, map.getOrDefault(sorted, 0)+1) map.put map sorted map.getOrDefault(sorted, 0)+1 map.getOrDefault(sorted, 0) map.getOrDefault map sorted 0 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    }
}

