import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collection; Collection java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.HashMap; HashMap java.util import java.util.List; List 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) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        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 String line; line char[] cline = new char[10]; cline new char[10] 10 String key = ""; key "" long value; value Map<String, Long> map = new HashMap<>(); map new HashMap<>() line = sc.nextLine() line sc.nextLine() sc.nextLine sc for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        } {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        } cline = sc.next().toCharArray() cline sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(cline) Arrays.sort Arrays cline key = String.valueOf(cline) key String.valueOf(cline) String.valueOf String cline if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            } map.containsKey(key) map.containsKey map key {
                value = map.get(key) + 1;
            } value = map.get(key) + 1 value map.get(key) + 1 map.get(key) map.get map key 1 {
                value = 1;
            } value = 1 value 1 map.put(key, value) map.put map key value Collection clct = map.values(); clct map.values() map.values map List<Long> array = new ArrayList<Long>(); array new ArrayList<Long>() array.addAll(clct) array.addAll array clct long count = 0; count 0 long pairs; pairs for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        } int i = 0; int i = 0; i 0 i < array.size() i array.size() array.size array i++ i++ i {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        } {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        } pairs = array.get(i) * (array.get(i) - 1) / 2 pairs array.get(i) * (array.get(i) - 1) / 2 array.get(i) * (array.get(i) - 1) array.get(i) array.get array i (array.get(i) - 1) array.get(i) array.get array i 1 2 count += pairs count pairs System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
 
        String line;
        char[] cline = new char[10];
        String key = "";
        long value;

        Map<String, Long> map = new HashMap<>();

        line = sc.nextLine();

        for (int i = 0; i < N; i++) {
            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);

            if (map.containsKey(key)) {
                value = map.get(key) + 1;
            } else {
                value = 1;
            }
            map.put(key, value);
        }


        // 綺麗に書けないしあまり意味も分かりきっていない箇所
        Collection clct = map.values();
        List<Long> array = new ArrayList<Long>();
        array.addAll(clct);
       // Collections.sort(array, Comparator.reverseOrder());

        long count = 0;
        long pairs;
        
        for (int i = 0; i < array.size(); i++) {
            pairs = array.get(i) * (array.get(i) - 1) / 2;
            count += pairs;
        }
        System.out.println(count);
    }
}