import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    } main {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        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 String[]po=new String[n]; po new String[n] n Map<String,Integer>map=new HashMap<>(); map new HashMap<>() for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        } {
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        } char po2[]=sc.next().toCharArray(); po2 sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(po2) Arrays.sort Arrays po2 po[i]=String.valueOf(po2) po[i] po i String.valueOf(po2) String.valueOf String po2 if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0); map.containsKey(po[i]) map.containsKey map po[i] po i {
                map.put(po[i],map.get(po[i])+1);
            } map.put(po[i],map.get(po[i])+1) map.put map po[i] po i map.get(po[i])+1 map.get(po[i]) map.get map po[i] po i 1 map.put(po[i],0) map.put map po[i] po i 0 Arrays.sort(po) Arrays.sort Arrays po long ans=0; ans 0 for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        } String key map.keySet() map.keySet map {
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        } {
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        } ans+=(long)(map.get(key))*(map.get(key)+1)/2 ans (long)(map.get(key))*(map.get(key)+1)/2 (long)(map.get(key))*(map.get(key)+1) (long)(map.get(key)) map.get map key (map.get(key)+1) map.get(key) map.get map key 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 sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[]po=new String[n];
        Map<String,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            char po2[]=sc.next().toCharArray();
            Arrays.sort(po2);
            po[i]=String.valueOf(po2);
            if(map.containsKey(po[i])){
                map.put(po[i],map.get(po[i])+1);
            }
            else 
                map.put(po[i],0);
        }
        Arrays.sort(po);
        long ans=0;
        for(String key:map.keySet()){
            ans+=(long)(map.get(key))*(map.get(key)+1)/2;
        }
        System.out.println(ans);
    }
}
