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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        System.out.println(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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        long count = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        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 = 0L; count 0L for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        } {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        } String s = sc.next(); s sc.next() sc.next sc char[] ar = s.toCharArray(); ar s.toCharArray() s.toCharArray s Arrays.sort(ar) Arrays.sort Arrays ar String key = new String(ar); key new String(ar) if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	} 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, 1L);
        	} map.put(key, 1L) map.put map key 1L 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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        System.out.println(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 = 0L;
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	char[] ar = s.toCharArray();
        	Arrays.sort(ar);
        	String key = new String(ar);
        	if (map.containsKey(key)) {
        		count += map.get(key);
        		map.put(key, map.get(key) + 1);
        	} else {
        		map.put(key, 1L);
        	}
        }
        System.out.println(count);
    }
}