import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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.println(count);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map 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();
		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.println(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.println(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.println(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.println(count) System.out.println 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.println(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.println(count);
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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.println(count);
	}
}
