import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    }
    
    public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    }
    
    public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    } main {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N  = sc.nextInt(); N sc.nextInt() sc.nextInt sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        } {
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        } String a = sc.next(); a sc.next() sc.next sc a = lexicalOrderSort(a) a lexicalOrderSort(a) lexicalOrderSort a if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            } map.containsKey(a) map.containsKey map a {
                Integer b = map.get(a);
                map.put(a, ++b);
            } Integer b = map.get(a); b map.get(a) map.get map a map.put(a, ++b) map.put map a ++b b {
                map.put(a, 1);
            } map.put(a, 1) map.put map a 1 long sum = 0; sum 0 for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        } Integer mapValue map.values() map.values map {
            sum += (long) mapValue * (mapValue - 1) / 2;
        } {
            sum += (long) mapValue * (mapValue - 1) / 2;
        } sum += (long) mapValue * (mapValue - 1) / 2 sum (long) mapValue * (mapValue - 1) / 2 (long) mapValue * (mapValue - 1) (long) mapValue (mapValue - 1) mapValue 1 2 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    } lexicalOrderSort {
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    } int[] schar = new int[10]; schar new int[10] 10 for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        } int i = 0; int i = 0; i 0 i < 10 i 10 i++ i++ i {
            int a = s.charAt(i);
            schar[i] = a;
        } {
            int a = s.charAt(i);
            schar[i] = a;
        } int a = s.charAt(i); a s.charAt(i) s.charAt s i schar[i] = a schar[i] schar i a Arrays.sort(schar) Arrays.sort Arrays schar StringBuilder sb = new StringBuilder(); sb new StringBuilder() for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        } int i = 0; int i = 0; i 0 i < 10 i 10 i++ i++ i {
            char a = (char) (schar[i]);
            sb.append(a);
        } {
            char a = (char) (schar[i]);
            sb.append(a);
        } char a = (char) (schar[i]); a (char) (schar[i]) schar i sb.append(a) sb.append sb a return sb.toString(); sb.toString() sb.toString sb String s s public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    }
    
    public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    }
    
    public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        
        Map<String, Integer> map = new HashMap<>();
        
        for(int i = 0; i < N; i++){
            String a = sc.next();
            
            // aを辞書順にソート
            a = lexicalOrderSort(a);
            
            if ( map.containsKey(a) ){
                Integer b = map.get(a);
                map.put(a, ++b);
            } else {
                map.put(a, 1);
            }
        }
        
        long sum = 0;
        for(Integer mapValue : map.values() ){
            sum += (long) mapValue * (mapValue - 1) / 2;
        }
        
        System.out.println(sum);
    }
    
    public static String lexicalOrderSort(String s){
        
        int[] schar = new int[10];
        for(int i = 0; i < 10; i++){
            int a = s.charAt(i);
            schar[i] = a;
        }
        
        Arrays.sort(schar);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < 10; i++){
            char a = (char) (schar[i]);
            sb.append(a);
        }
        
        return sb.toString();
        
    }
}
