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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in HashMap<String, Long> map = new HashMap<>(); map new HashMap<>() long total = 0; total 0 for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		} {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		} char[] s = in.next().toCharArray(); s in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(s) Arrays.sort Arrays s String key = new String(s); key new String(s) Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1); cnt (map.containsKey(key) ? map.get(key) + 1 : 1) map.containsKey(key) map.containsKey map key map.get(key) + 1 map.get(key) map.get map key 1 1 map.put(key, cnt) map.put map key cnt for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        } Long l map.values() map.values map {
            total = total + (l * (l -1) / 2);
        } {
            total = total + (l * (l -1) / 2);
        } total = total + (l * (l -1) / 2) total total + (l * (l -1) / 2) total (l * (l -1) / 2) l * (l -1) l (l -1) l 1 2 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
		}
        for(Long l: map.values()){
            total = total + (l * (l -1) / 2);
        }
		System.out.println(total);

	}
}