import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  }
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  }
} Main public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  } main {
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long count = 0; count 0 HashMap<String,Long> map = new HashMap<>(); map new HashMap<>() for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  } int i=0; int i=0; i 0 i<N i N i++ i++ i {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  } {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  } String s = sc.next(); s sc.next() sc.next sc char[] c = s.toCharArray(); c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c String sorted = new String(c); sorted new String(c) if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  } !map.containsKey(sorted) map.containsKey(sorted) map.containsKey map sorted {
			   map.put(sorted, (long) 0);
		  } map.put(sorted, (long) 0) map.put map sorted (long) 0 {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  } long n = map.get(sorted) + 1; n map.get(sorted) + 1 map.get(sorted) map.get map sorted 1 count += n count n map.put(sorted, n) map.put map sorted n out.println(count) out.println out count String[] args args public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  }
} public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  }
} Main
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long count = 0;
	  HashMap<String,Long> map = new HashMap<>();
	  for(int i=0; i<N; i++) {
		  String s = sc.next();
		  char[] c = s.toCharArray();
		  Arrays.sort(c);
		  String sorted = new String(c);
		  //文字列が初出のとき
		  if (!map.containsKey(sorted)) {
			   map.put(sorted, (long) 0);
		  } else {
			  long n = map.get(sorted) + 1;
			  count += n;
			  map.put(sorted, n);
		  }
  }
  out.println(count);	  
  }
}