import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    } main {
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc char[][] c = new char[n][]; c new char[n][] n long cnt = 0; cnt 0 HashMap<String,Integer> map = new HashMap<String,Integer>(); map new HashMap<String,Integer>() String s = ""; s "" for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      } {
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      } c[i] = sc.next().toCharArray() c[i] c i sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c[i]) Arrays.sort Arrays c[i] c i for(int j= 0;j < 10;j++)s += c[i][j]; int j= 0; int j= 0; j 0 j < 10 j 10 j++ j++ j s += c[i][j]; s += c[i][j] s c[i][j] c[i] c i j if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        } map.get(s)==null map.get(s) map.get map s null {
        	map.put(s,1);
        } map.put(s,1) map.put map s 1 {
          int k = map.get(s);
          map.put(s,k+1);
        } int k = map.get(s); k map.get(s) map.get map s map.put(s,k+1) map.put map s k+1 k 1 s = "" s "" for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      } int a map.values() map.values map {
      	cnt += (long)a*(a-1)/2;
      } {
      	cnt += (long)a*(a-1)/2;
      } cnt += (long)a*(a-1)/2 cnt (long)a*(a-1)/2 (long)a*(a-1) (long)a (a-1) a 1 2 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[][] c = new char[n][];
      long cnt = 0;
      HashMap<String,Integer> map = new HashMap<String,Integer>();
      String s = "";
      for(int i = 0;i < n;i++){
      	c[i] = sc.next().toCharArray();
        Arrays.sort(c[i]);
        for(int j= 0;j < 10;j++)s += c[i][j];
        if(map.get(s)==null){
        	map.put(s,1);
        }else{
          int k = map.get(s);
          map.put(s,k+1);
        }
        s = "";
      }
      for(int a:map.values()){
      	cnt += (long)a*(a-1)/2;
      }
      System.out.println(cnt);
    }
}
