import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    } 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 ArrayList<String> list = new ArrayList<>(); list new ArrayList<>() for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        } {
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        } char[]c = sc.nextLine().toCharArray(); c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc Arrays.sort(c) Arrays.sort Arrays c list.add(new String(c)) list.add list new String(c) Collections.sort(list) Collections.sort Collections list long anagram = 0; anagram 0 long answer = 0; answer 0 String s = list.get(0); s list.get(0) list.get list 0 for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        } {
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        } if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            } s.equals(list.get(i)) s.equals s list.get(i) list.get list i {
                anagram += 1;
            } anagram += 1 anagram 1 {
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            } long a = 0; a 0 for(long j = 0; j < anagram; j++){
                    a += j+1;
                } long j = 0; long j = 0; j 0 j < anagram j anagram j++ j++ j {
                    a += j+1;
                } {
                    a += j+1;
                } a += j+1 a j+1 j 1 answer += a answer a anagram = 0 anagram 0 s = list.get(i) s list.get(i) list.get list i if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        } list.get(n-1).equals(list.get(n-2)) list.get(n-1).equals list.get(n-1) list.get list n-1 n 1 list.get(n-2) list.get list n-2 n 2 {
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        } long a = 0; a 0 for(long i = 0; i < anagram; i++){
                a += i+1;
            } long i = 0; long i = 0; i 0 i < anagram i anagram i++ i++ i {
                a += i+1;
            } {
                a += i+1;
            } a += i+1 a i+1 i 1 answer += a answer a System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
} public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> list = new ArrayList<>();
        
        for(int i = 0; i < n; i++){
            char[]c = sc.nextLine().toCharArray();
            Arrays.sort(c);
            list.add(new String(c));
        }
        
        Collections.sort(list);
        
        long anagram = 0;
        long answer = 0;
        String s = list.get(0);
        for(int i = 1; i < n; i++){
            if(s.equals(list.get(i))){
                anagram += 1;
            }else{
                long a = 0;
                for(long j = 0; j < anagram; j++){
                    a += j+1;
                }
                answer += a;
                anagram = 0;
                s = list.get(i);
            }
        }
        if(list.get(n-1).equals(list.get(n-2))){
            long a = 0;
            for(long i = 0; i < anagram; i++){
                a += i+1;
            }
            answer += a;
        }
        
        System.out.println(answer);
    }
}