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 = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
} 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 = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
} Main public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		    int n = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	} main {
		    Scanner sc = new Scanner(System.in);

		    int n = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String[] s = new String[n]; s new String[n] n String[] ss = new String[n]; ss new String[n] n for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    } {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    } s[i] = sc.next() s[i] s i sc.next() sc.next sc char[] chars = new char[10]; chars new char[10] 10 chars = s[i].toCharArray() chars s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(chars) Arrays.sort Arrays chars ss[i] = new String(chars) ss[i] ss i new String(chars) Arrays.sort(ss) Arrays.sort Arrays ss long cnt = 0; cnt 0 long cnt1 = 0; cnt1 0 for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    } {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    } if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	} ss[i].equals(ss[i+1]) ss[i].equals ss[i] ss i ss[i+1] ss i+1 i 1 {
		    		cnt1++;
		    		cnt+=cnt1;
		    	} cnt1++ cnt1 cnt+=cnt1 cnt cnt1 {
		    		cnt1=0;
		    	} cnt1=0 cnt1 0 System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		    int n = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		    int n = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
} 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 = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
}
