
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] s = new String[n]; s new String[n] n for(int i=0;i<n;i++){
            s[i] = sc.next();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            s[i] = sc.next();
        } {
            s[i] = sc.next();
        } s[i] = sc.next() s[i] s i sc.next() sc.next sc Map<List<String>, Integer> codes = new HashMap<>(); codes new HashMap<>() long count = 0; count 0 for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        } {
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        } String[] st = s[i].split(""); st s[i].split("") s[i].split s[i] s i "" Arrays.sort(st) Arrays.sort Arrays st List<String> str = Arrays.asList(st); str Arrays.asList(st) Arrays.asList Arrays st if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            } codes.containsKey(str) codes.containsKey codes str {
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            } int tmp = codes.get(str); tmp codes.get(str) codes.get codes str count += (long)tmp count (long)tmp codes.put(str, tmp+1) codes.put codes str tmp+1 tmp 1 {
                codes.put(str, 1);
            } codes.put(str, 1) codes.put codes str 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    }
} Main

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] s = new String[n];
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        Map<List<String>, Integer> codes = new HashMap<>();
        long count = 0;
        for(int i=0;i<n;i++){
            String[] st = s[i].split("");
            Arrays.sort(st);
            List<String> str = Arrays.asList(st);
            if(codes.containsKey(str)){
                int tmp = codes.get(str);
                count += (long)tmp;
                codes.put(str, tmp+1);
            }
            else{
                codes.put(str, 1);
            }
        }
        System.out.println(count);
    }
}