import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    }
} import java.util.*; util.* java class Main {
    public static void main(String args[]) {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    }
} Main public static void main(String args[]) {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    } main {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    } Scanner s  = new Scanner(System.in); s new Scanner(System.in) int n n i i x; x long count; count String str=""; str "" char arr[]; arr n = s.nextInt() n s.nextInt() s.nextInt s HashMap<String, Integer> hm = new HashMap<String, Integer>(); hm new HashMap<String, Integer>() for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        } i=0; i=0 i 0 i<n i n i++ i++ i {
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        } {
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        } str = s.next() str s.next() s.next s arr = str.toCharArray() arr str.toCharArray() str.toCharArray str Arrays.sort(arr) Arrays.sort Arrays arr str  = new String(arr) str new String(arr) if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1); hm.containsKey(str) hm.containsKey hm str hm.put(str, hm.get(str)+1) hm.put hm str hm.get(str)+1 hm.get(str) hm.get hm str 1 hm.put(str, 1) hm.put hm str 1 count = 0l count 0l Iterator itr = hm.entrySet().iterator(); itr hm.entrySet().iterator() hm.entrySet().iterator hm.entrySet() hm.entrySet hm while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        } itr.hasNext() itr.hasNext itr {
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        } Map.Entry me = (Map.Entry)itr.next(); me (Map.Entry)itr.next() itr.next itr x = (int)me.getValue() x (int)me.getValue() me.getValue me count += (((long)x)*((long)(x-1)))/2 count (((long)x)*((long)(x-1)))/2 (((long)x)*((long)(x-1))) ((long)x) ((long)(x-1)) x 1 2 System.out.println("" + count) System.out.println System.out System System.out "" + count "" count String args[] args
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner s  = new Scanner(System.in);
        int n, i, x;
        long count;
        String str="";
        char arr[];
        n = s.nextInt();
        HashMap<String, Integer> hm = new HashMap<String, Integer>();
        for(i=0; i<n; i++){
            str = s.next();
            arr = str.toCharArray();
            Arrays.sort(arr);
            str  = new String(arr);
            if(hm.containsKey(str))
                hm.put(str, hm.get(str)+1);
            else
                hm.put(str, 1);
        }
        
        count = 0l;
        Iterator itr = hm.entrySet().iterator();
        while(itr.hasNext()){
            Map.Entry me = (Map.Entry)itr.next();
            x = (int)me.getValue();
            count += (((long)x)*((long)(x-1)))/2;
        }
      System.out.println("" + count);
    }
}