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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	}
	public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	}
}
 import java.util.Arrays; Arrays 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();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	}
	public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc String[] buff=new String[n]; buff new String[n] n long count=0 count 0 sum=0; sum 0 for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		} {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		} buff[i]=sc.next() buff[i] buff i sc.next() sc.next sc buff[i]=sortS(buff[i]) buff[i] buff i sortS(buff[i]) sortS buff[i] buff i Arrays.sort(buff) Arrays.sort Arrays buff for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		} int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		} {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		} if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			} buff[i].equals(buff[i+1]) buff[i].equals buff[i] buff i buff[i+1] buff i+1 i 1 count++ count {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			} if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				} count>=1 count 1 {
					sum+=(long)(0.5*count*(count+1));
				} sum+=(long)(0.5*count*(count+1)) sum (long)(0.5*count*(count+1)) 0.5*count*(count+1) 0.5 count (count+1) count 1 count=0 count 0 if(count!=0)sum+=(long)(0.5*count*(count+1)); count!=0 count 0 sum+=(long)(0.5*count*(count+1)) sum (long)(0.5*count*(count+1)) 0.5*count*(count+1) 0.5 count (count+1) count 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	} sortS {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	} char[] sort = new char[s.length()]; sort new char[s.length()] s.length() s.length s String res=""; res "" for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		} int i=0; int i=0; i 0 i<sort.length i sort.length sort sort.length i++ i++ i {
			sort[i]=s.charAt(i);
		} {
			sort[i]=s.charAt(i);
		} sort[i]=s.charAt(i) sort[i] sort i s.charAt(i) s.charAt s i Arrays.sort(sort) Arrays.sort Arrays sort for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		} int i=0; int i=0; i 0 i<sort.length i sort.length sort sort.length i++ i++ i {
			res+=String.valueOf(sort[i]);
		} {
			res+=String.valueOf(sort[i]);
		} res+=String.valueOf(sort[i]) res String.valueOf(sort[i]) String.valueOf String sort[i] sort i return res; res String s s public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	}
	public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	}
	public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String[] buff=new String[n];
		long count=0,sum=0;

		for(int i=0;i<n;i++) {
			buff[i]=sc.next();
			buff[i]=sortS(buff[i]);
		}
		Arrays.sort(buff);
		for(int i=0;i<n-1;i++) {
			if(buff[i].equals(buff[i+1]))count++;
			else {
				if(count>=1) {
					sum+=(long)(0.5*count*(count+1));
				}
				count=0;
			}
			//System.out.println("count:"+count+" sum:"+sum);
		}
		if(count!=0)sum+=(long)(0.5*count*(count+1));
		System.out.println(sum);
	}
	public static String sortS(String s) {
		char[] sort = new char[s.length()];
		String res="";
		for(int i=0;i<sort.length;i++) {
			sort[i]=s.charAt(i);
		}
		Arrays.sort(sort);
		for(int i=0;i<sort.length;i++) {
			res+=String.valueOf(sort[i]);
		}
		return res;
	}
}

