
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.LongStream;

import javax.swing.Spring;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
} import java.io.PrintStream; PrintStream java.io import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Map.Entry; Entry java.util.Map import java.util.Scanner; Scanner java.util import java.util.stream.LongStream; LongStream java.util.stream import javax.swing.Spring; Spring javax.swing public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
} Main static final Scanner     sc = new Scanner(System.in); sc new Scanner(System.in) static final PrintStream so = System.out; so System.out System System.out public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    } main {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    } int N = nint(); N nint() nint String[] s = nstrs(N); s nstrs(N) nstrs N Map<String, Long> count = new HashMap<>(); count new HashMap<>() for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        } String e s {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        } {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        } String sorted = sort(e); sorted sort(e) sort e if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            } !count.containsKey(sorted) count.containsKey(sorted) count.containsKey count sorted {
                count.put(sorted, 1L);
            } count.put(sorted, 1L) count.put count sorted 1L {
                count.put(sorted, count.get(sorted) + 1L);
            } count.put(sorted, count.get(sorted) + 1L) count.put count sorted count.get(sorted) + 1L count.get(sorted) count.get count sorted 1L long ans = 0; ans 0 for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        } Entry<String, Long> e count.entrySet() count.entrySet count {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        } {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        } long p = e.getValue(); p e.getValue() e.getValue e ans += p * (p-1) / 2 ans p * (p-1) / 2 p * (p-1) p (p-1) p 1 2 so.println(ans) so.println so ans String[] args args private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    } sort {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    } char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c return String.valueOf(c); String.valueOf(c) String.valueOf String c String s s private static long nlong() {
        return sc.nextLong();
    } nlong {
        return sc.nextLong();
    } return sc.nextLong(); sc.nextLong() sc.nextLong sc private static int nint() {
        return sc.nextInt();
    } nint {
        return sc.nextInt();
    } return sc.nextInt(); sc.nextInt() sc.nextInt sc private static String nstr() {
        return sc.next();
    } nstr {
        return sc.next();
    } return sc.next(); sc.next() sc.next sc private static char[] nsToChars() {
        return sc.next().toCharArray();
    } nsToChars {
        return sc.next().toCharArray();
    } return sc.next().toCharArray(); sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    } nlongs {
        return nlongs(n, 0, 0);
    } return nlongs(n, 0, 0); nlongs(n, 0, 0) nlongs n 0 0 int n n private static int[] nints(int n) {
        return nints(n, 0, 0);
    } nints {
        return nints(n, 0, 0);
    } return nints(n, 0, 0); nints(n, 0, 0) nints n 0 0 int n n private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    } nints {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    } int[] a = new int[padL + n + padR]; a new int[padL + n + padR] padL + n + padR padL + n + padR padL n padR for (int i = 0; i < n; i++)
            a[padL + i] = nint(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[padL + i] = nint(); a[padL + i] = nint() a[padL + i] a padL + i padL i nint() nint return a; a int n n int padL padL int padR padR private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    } nlongs {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    } long[] a = new long[padL + n + padR]; a new long[padL + n + padR] padL + n + padR padL + n + padR padL n padR for (int i = 0; i < n; i++)
            a[padL + i] = nlong(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[padL + i] = nlong(); a[padL + i] = nlong() a[padL + i] a padL + i padL i nlong() nlong return a; a int n n int padL padL int padR padR private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    } nstrs {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    } String[] a = new String[n]; a new String[n] n for (int i = 0; i < n; i++)
            a[i] = nstr(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nstr(); a[i] = nstr() a[i] a i nstr() nstr return a; a int n n private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    } nsToChars2D {
        return nsToChars2D(h, w, 0);
    } return nsToChars2D(h, w, 0); nsToChars2D(h, w, 0) nsToChars2D h w 0 int h h int w w private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    } nsToChars2D {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    } char[][] a2 = new char[h + pad * 2][w + pad * 2]; a2 new char[h + pad * 2][w + pad * 2] h + pad * 2 h pad * 2 pad 2 w + pad * 2 w pad * 2 pad 2 for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w); int i = 0; int i = 0; i 0 i < h i h i++ i++ i System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w); System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w) System.arraycopy System nsToChars() nsToChars 0 a2[pad + i] a2 pad + i pad i pad w return a2; a2 int h h int w w int pad pad public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
} public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
} Main

import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.LongStream;

import javax.swing.Spring;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}
