import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    } main {
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan long answer = 0; answer 0 Map<String, Long> map = new HashMap<>(); map new HashMap<>() for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        } int i = 0 ; int i = 0 ; i 0 i < n i n i ++ i ++ i {
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        } {
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        } String s = scan.next(); s scan.next() scan.next scan String[] k = s.split(""); k s.split("") s.split s "" Arrays.sort(k) Arrays.sort Arrays k String sortedstr = String.join("", k); sortedstr String.join("", k) String.join String "" k if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            } map.containsKey(sortedstr) map.containsKey map sortedstr {
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            } answer += map.get(sortedstr) answer map.get(sortedstr) map.get map sortedstr map.put(sortedstr, (map.get(sortedstr) + 1)) map.put map sortedstr (map.get(sortedstr) + 1) map.get(sortedstr) map.get map sortedstr 1 {
            	map.put(sortedstr, (long)1);
            } map.put(sortedstr, (long)1) map.put map sortedstr (long)1 System.out.print(answer) System.out.print System.out System System.out answer String[] args args public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    }
} Main
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int n = scan.nextInt();
      	long answer = 0;
      	Map<String, Long> map = new HashMap<>();
      	for(int i = 0 ; i < n ; i ++){
        	String s = scan.next();
          	String[] k = s.split("");
          	Arrays.sort(k);
          	String sortedstr = String.join("", k);
          	//String sortedstr = new String(k);
          	if(map.containsKey(sortedstr)){
              	answer += map.get(sortedstr);
          		map.put(sortedstr, (map.get(sortedstr) + 1)); 	
            }
          	else{
            	map.put(sortedstr, (long)1);
            }
        }
      	
      	System.out.print(answer);
    }
}