import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
} Main long INF = Long.MAX_VALUE; INF Long.MAX_VALUE Long Long.MAX_VALUE long[][] dp; dp public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    } solve {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        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[] 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 char[][] s = new char[N][]; s new char[N][] N for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        } {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        } s[i] = S[i].toCharArray() s[i] s i S[i].toCharArray() S[i].toCharArray S[i] S i Arrays.sort(s[i]) Arrays.sort Arrays s[i] s i for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            S[i] = String.valueOf(s[i]);
        } {
            S[i] = String.valueOf(s[i]);
        } S[i] = String.valueOf(s[i]) S[i] S i String.valueOf(s[i]) String.valueOf String s[i] s i Arrays.sort(S) Arrays.sort Arrays S long ans = 0; ans 0 long count = 1; count 1 for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        } {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        } if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            } S[i].equals(S[i - 1]) S[i].equals S[i] S i S[i - 1] S i - 1 i 1 {
                count++;
            } count++ count {
                ans += count * (count - 1) / 2;
                count = 1;
            } ans += count * (count - 1) / 2 ans count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 count = 1 count 1 ans += count * (count - 1) / 2 ans count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 count = 1 count 1 System.out.println(ans) System.out.println System.out System System.out ans public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
} public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        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();
        }
        char[][] s = new char[N][];
        for (int i = 0; i < N; i++) {
            s[i] = S[i].toCharArray();
            Arrays.sort(s[i]);
        }
        for (int i = 0; i < N; i++) {
            S[i] = String.valueOf(s[i]);
        }
        Arrays.sort(S);
        long ans = 0;
        long count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i].equals(S[i - 1])) {
                count++;
            } else {
                ans += count * (count - 1) / 2;
                count = 1;
            }
        }
        ans += count * (count - 1) / 2;
        count = 1;
        System.out.println(ans);
    }
}