import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 }
 
 public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 }
 
} import java.util.*; util.* java public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 }
 
 public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 }
 
} Main public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 } main {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc String x=sc.nextLine(); x sc.nextLine() sc.nextLine sc Map<String, Long> log = new HashMap<String, Long>(); log new HashMap<String, Long>() long r=0L; r 0L for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	} int i=0; int i=0; i 0 i<N i N i++ i++ i {
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	} {
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	} String s=sc.nextLine(); s sc.nextLine() sc.nextLine sc s=sort(s) s sort(s) sort s if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		} log.containsKey(s) log.containsKey log s {
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		} r+=log.get(s) r log.get(s) log.get log s log.put(s,log.get(s)+1) log.put log s log.get(s)+1 log.get(s) log.get log s 1 {
			log.put(s,1L);
		} log.put(s,1L) log.put log s 1L System.out.println(r) System.out.println System.out System System.out r String[] args args public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 } sort {
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 } char[] ana=new char[10]; ana new char[10] 10 for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	} int j=0; int j=0; j 0 j<10 j 10 j++ j++ j {
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	} {
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	} String k=s.substring(j,j+1); k s.substring(j,j+1) s.substring s j j+1 j 1 ana[j]=k.toCharArray()[0] ana[j] ana j k.toCharArray()[0] k.toCharArray() k.toCharArray k 0 Arrays.sort(ana) Arrays.sort Arrays ana return String.valueOf(ana); String.valueOf(ana) String.valueOf String ana String s s public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 }
 
 public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 }
 
} public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 }
 
 public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 }
 
} Main
import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String x=sc.nextLine();//次の行に行く方法？？？
	Map<String, Long> log = new HashMap<String, Long>();
	long r=0L;


	for(int i=0;i<N;i++){
		String s=sc.nextLine();
		s=sort(s);
		
		if(log.containsKey(s)){
			r+=log.get(s);
			log.put(s,log.get(s)+1);
		}else{
			log.put(s,1L);
		}
	}
	System.out.println(r);
 }
 
 public static String sort(String s){
	char[] ana=new char[10];
	for(int j=0;j<10;j++){
		String k=s.substring(j,j+1);
		 ana[j]=k.toCharArray()[0];
	}
	Arrays.sort(ana);
	return String.valueOf(ana);
 }
 
}