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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
}
 import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long ans = 0; ans 0 HashMap<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        } {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        } char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String s = String.valueOf(c); s String.valueOf(c) String.valueOf String c if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            } map.containsKey(s) map.containsKey map s {
                map.put(s,map.get(s)+1);
            } map.put(s,map.get(s)+1) map.put map s map.get(s)+1 map.get(s) map.get map s 1 {
                map.put(s,1);
            } map.put(s,1) map.put map s 1 for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		} Map.Entry<String, Integer> entry map.entrySet() map.entrySet map {
		    ans += calcComb(entry.getValue());
		} {
		    ans += calcComb(entry.getValue());
		} ans += calcComb(entry.getValue()) ans calcComb(entry.getValue()) calcComb entry.getValue() entry.getValue entry System.out.println(ans) System.out.println System.out System System.out ans String[] args args static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    } calcComb {
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    } long ret = (long)n; ret (long)n return ((ret*ret)-ret)/2; ((ret*ret)-ret)/2 ((ret*ret)-ret) (ret*ret) ret ret ret 2 int n n public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
} Main
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
}

