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

    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        }
    } import java.util.*; util.* java import java.io.*; io.* java public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        }
    } Main public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        } main {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n=in.nextInt(); n in.nextInt() in.nextInt in String[] sList = new String[n]; sList new String[n] n for(int i=0;i<n;i++)
                sList[i]=in.next(); int i=0; int i=0; i 0 i<n i n i++ i++ i sList[i]=in.next(); sList[i]=in.next() sList[i] sList i in.next() in.next in HashMap<String,Long> freqMap = new HashMap<>(); freqMap new HashMap<>() for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            } {
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            } char[] cur= sList[i].toCharArray(); cur sList[i].toCharArray() sList[i].toCharArray sList[i] sList i Arrays.sort(cur) Arrays.sort Arrays cur String temp = new String(cur); temp new String(cur) if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L); !freqMap.containsKey(temp) freqMap.containsKey(temp) freqMap.containsKey freqMap temp freqMap.put(temp,0L) freqMap.put freqMap temp 0L freqMap.put(temp,freqMap.get(temp)+1) freqMap.put freqMap temp freqMap.get(temp)+1 freqMap.get(temp) freqMap.get freqMap temp 1 long ans=0; ans 0 for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2; String x freqMap.keySet() freqMap.keySet freqMap ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2; ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2 ans (1L*freqMap.get(x)*(freqMap.get(x)-1))/2 (1L*freqMap.get(x)*(freqMap.get(x)-1)) 1L*freqMap.get(x)*(freqMap.get(x)-1) 1L freqMap.get(x) freqMap.get freqMap x (freqMap.get(x)-1) freqMap.get(x) freqMap.get freqMap x 1 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        }
    } public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        }
    } Main
    import java.util.*;
    import java.io.*;

    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n=in.nextInt();
            String[] sList = new String[n];
            for(int i=0;i<n;i++)
                sList[i]=in.next();
            HashMap<String,Long> freqMap = new HashMap<>();
            for(int i=0;i<n;i++){
                char[] cur= sList[i].toCharArray();
                Arrays.sort(cur);
                String temp = new String(cur);
                if(!freqMap.containsKey(temp))
                    freqMap.put(temp,0L);
                freqMap.put(temp,freqMap.get(temp)+1);
            }   
            long ans=0;
            for(String x:freqMap.keySet())
                ans+=(1L*freqMap.get(x)*(freqMap.get(x)-1))/2;
            System.out.println(ans);
        }
    }