import java.util.*;

public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    }
    }

//    public static boolean comp(char[] c1, char []c2){
//
//        Arrays.sort(c1);
//        Arrays.sort(c2);
//        if (Arrays.equals(c1, c2)){
//            return true;
//        }else{
//            return false;
//        }
//    }
//} import java.util.*; util.* java public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    }
    } Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String str[] = new String[n]; str new String[n] n for (int i = 0; i < n; i++) str[i] = sc.next(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i str[i] = sc.next(); str[i] = sc.next() str[i] str i sc.next() sc.next sc for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        } {
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        } char c[] = str[i].toCharArray(); c str[i].toCharArray() str[i].toCharArray str[i] str i Arrays.sort(c) Arrays.sort Arrays c str[i] = Arrays.toString(c) str[i] str i Arrays.toString(c) Arrays.toString Arrays c Map<String, Long> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        } {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        } if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            } map.containsKey(str[i]) map.containsKey map str[i] str i {
                map.put(str[i], map.get(str[i]) + 1);
            } map.put(str[i], map.get(str[i]) + 1) map.put map str[i] str i map.get(str[i]) + 1 map.get(str[i]) map.get map str[i] str i 1 {
                map.put(str[i], 1l);
            } map.put(str[i], 1l) map.put map str[i] str i 1l long sum = 0; sum 0 for (long i: map.values()){
            sum += i*(i-1)/2;
        } long i map.values() map.values map {
            sum += i*(i-1)/2;
        } {
            sum += i*(i-1)/2;
        } sum += i*(i-1)/2 sum i*(i-1)/2 i*(i-1) i (i-1) i 1 2 System.out.print(sum) System.out.print System.out System System.out sum String args[] args public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    }
    } public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    }
    } Main
import java.util.*;

public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) str[i] = sc.next();

        for (int i=0 ;i<n; i++){
            char c[] = str[i].toCharArray();
            Arrays.sort(c);
            str[i] = Arrays.toString(c);
        }

//        for (int i=0; i<n; i++)

        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {

            if (map.containsKey(str[i])) {
                map.put(str[i], map.get(str[i]) + 1);
            } else {
                map.put(str[i], 1l);
            }
        }

        long sum = 0;
        for (long i: map.values()){
            sum += i*(i-1)/2;
        }
        System.out.print(sum);
//        System.out.print(str[0]);

    }
    }

//    public static boolean comp(char[] c1, char []c2){
//
//        Arrays.sort(c1);
//        Arrays.sort(c2);
//        if (Arrays.equals(c1, c2)){
//            return true;
//        }else{
//            return false;
//        }
//    }
//}