import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        }
        solve(N, s);
    }

    static void solve(long N, String[] s){
        HashMap<String, Long> hm = new HashMap<>();
        for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        }

        long ans = 0;
        for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        }
        System.out.println(ans);

        



    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        }
        solve(N, s);
    }

    static void solve(long N, String[] s){
        HashMap<String, Long> hm = new HashMap<>();
        for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        }

        long ans = 0;
        for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        }
        System.out.println(ans);

        



    }
} Main public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        }
        solve(N, s);
    } main {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        }
        solve(N, s);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N; N N = sc.nextLong() N sc.nextLong() sc.nextLong sc String[] s = new String[(int)(N)]; s new String[(int)(N)] (int)(N) for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
                s[i] = sc.next();
        } {
                s[i] = sc.next();
        } s[i] = sc.next() s[i] s i sc.next() sc.next sc solve(N, s) solve N s String[] args args static void solve(long N, String[] s){
        HashMap<String, Long> hm = new HashMap<>();
        for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        }

        long ans = 0;
        for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        }
        System.out.println(ans);

        



    } solve {
        HashMap<String, Long> hm = new HashMap<>();
        for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        }

        long ans = 0;
        for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        }
        System.out.println(ans);

        



    } HashMap<String, Long> hm = new HashMap<>(); hm new HashMap<>() for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        } String si s {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        } {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        } char[] ca = si.toCharArray(); ca si.toCharArray() si.toCharArray si Arrays.sort(ca) Arrays.sort Arrays ca Long val = hm.get(new String(ca)); val hm.get(new String(ca)) hm.get hm new String(ca) if(val == null) {
                val = (long)1;
            } else {
                val++;
            } val == null val null {
                val = (long)1;
            } val = (long)1 val (long)1 {
                val++;
            } val++ val val = hm.put(new String(ca), val) val hm.put(new String(ca), val) hm.put hm new String(ca) val long ans = 0; ans 0 for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        } Map.Entry<String, Long> entry hm.entrySet() hm.entrySet hm {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        } {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        } long v = entry.getValue(); v entry.getValue() entry.getValue entry ans += v * (v-1) / 2 ans v * (v-1) / 2 v * (v-1) v (v-1) v 1 2 System.out.println(ans) System.out.println System.out System System.out ans long N N String[] s s
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
        }
        solve(N, s);
    }

    static void solve(long N, String[] s){
        HashMap<String, Long> hm = new HashMap<>();
        for (String si : s) {
            char[] ca = si.toCharArray();
            Arrays.sort(ca);
            Long val = hm.get(new String(ca));
            if(val == null) {
                val = (long)1;
            } else {
                val++;
            }
            val = hm.put(new String(ca), val);
        }

        long ans = 0;
        for (Map.Entry<String, Long> entry: hm.entrySet()) {
            long v = entry.getValue();
            ans += v * (v-1) / 2;
        }
        System.out.println(ans);

        



    }
}
