import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc String[] strz = new String[N]; strz new String[N] N for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        } int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
            strz[n] = sc.nextLine();
        } {
            strz[n] = sc.nextLine();
        } strz[n] = sc.nextLine() strz[n] strz n sc.nextLine() sc.nextLine sc for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        } int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        } {
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        } char[] charn = strz[n].toCharArray(); charn strz[n].toCharArray() strz[n].toCharArray strz[n] strz n Arrays.sort(charn) Arrays.sort Arrays charn strz[n] = new String(charn) strz[n] strz n new String(charn) Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        } String s strz {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        } {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        } Integer i = map.get(s); i map.get(s) map.get map s map.put(s, i == null ? 1 : i + 1) map.put map s i == null ? 1 : i + 1 i == null i null 1 i + 1 i 1 long cnt = 0; cnt 0 for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        } String key map.keySet() map.keySet map {
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        } {
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        } long num = map.get(key); num map.get(key) map.get map key if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            } num > 1 num 1 {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            } cnt+= (num*(num-1)/2) cnt (num*(num-1)/2) num*(num-1) num (num-1) num 1 2 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    } f {
        if (n<=1){return 1;}
        return f(n-1)*n;
    } if (n<=1){return 1;} n<=1 n 1 {return 1;} return 1; 1 return f(n-1)*n; f(n-1)*n f(n-1) f n-1 n 1 n long n n public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    } conbi {
        return (f(n)/(f(n-r)*f(r)));
    } return (f(n)/(f(n-r)*f(r))); (f(n)/(f(n-r)*f(r))) f(n) f n (f(n-r)*f(r)) f(n-r) f n-r n r f(r) f r long n n long r r public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
}
