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