import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        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 = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Map<String,Long> map = new HashMap<>(); map new HashMap<>() long ans = 0; ans 0 for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        } {
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        } char[] tmp = sc.next().toCharArray(); tmp sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(tmp) Arrays.sort Arrays tmp String key = String.valueOf(tmp); key String.valueOf(tmp) String.valueOf String tmp if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            } map.get(key) != null map.get(key) map.get map key null {
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            } ans += map.get(key) ans map.get(key) map.get map key map.put(key,map.get(key) + 1) map.put map key map.get(key) + 1 map.get(key) map.get map key 1 {
                map.put(key,1L);
            } map.put(key,1L) map.put map key 1L 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 = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        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 = Integer.parseInt(sc.next());
        Map<String,Long> map = new HashMap<>();
        long ans = 0;
        for(int i = 0;i<n;i++){
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String key = String.valueOf(tmp);
            if(map.get(key) != null){
                ans += map.get(key);
                map.put(key,map.get(key) + 1);
            }else{
                map.put(key,1L);
            }
        }
        System.out.println(ans);
    }
}