import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    }

}
 import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import static java.lang.Math.max; import static java.lang.Math.max; import static java.lang.Math.max; public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    }

} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner String[] s = new String[n]; s new String[n] n long count = 0; count 0 int tmpCount = 1; tmpCount 1 for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        } {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        } char[] tmp = scanner.next().toCharArray(); tmp scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner Arrays.sort(tmp) Arrays.sort Arrays tmp s[i] = String.valueOf(tmp) s[i] s i String.valueOf(tmp) String.valueOf String tmp Arrays.sort(s) Arrays.sort Arrays s for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        } {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        } if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            } s[i-1].equals(s[i]) s[i-1].equals s[i-1] s i-1 i 1 s[i] s i {
                count += tmpCount;
                tmpCount++;
            } count += tmpCount count tmpCount tmpCount++ tmpCount {
                tmpCount = 1;
            } tmpCount = 1 tmpCount 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) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    }

} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    }

} Main
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] s = new String[n];
        long count = 0;
        int tmpCount = 1;

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            Arrays.sort(tmp);
            s[i] = String.valueOf(tmp);
        }

        Arrays.sort(s);

        for (int i = 1; i < n; i++) {
            if(s[i-1].equals(s[i])) {
                count += tmpCount;
                tmpCount++;
            } else {
                tmpCount = 1;
            }
        }
        System.out.println(count);

    }

}

