import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    }

    private static long comb(long a) {
    	return a * (a - 1) / 2;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    }

    private static long comb(long a) {
    	return a * (a - 1) / 2;
    }
} Main public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Map<String, Integer> wordFreq = new HashMap<>(); wordFreq new HashMap<>() for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        } {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        } String word = sc.next(); word sc.next() sc.next sc char[] arr = word.toCharArray(); arr word.toCharArray() word.toCharArray word Arrays.sort(arr) Arrays.sort Arrays arr String newWord = new String(arr); newWord new String(arr) wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1) wordFreq.put wordFreq newWord wordFreq.getOrDefault(newWord, 0) + 1 wordFreq.getOrDefault(newWord, 0) wordFreq.getOrDefault wordFreq newWord 0 1 long res = 0; res 0 for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        } Integer freq wordFreq.values() wordFreq.values wordFreq {
        	if(freq < 2) continue;
        	res += comb(freq);
        } {
        	if(freq < 2) continue;
        	res += comb(freq);
        } if(freq < 2) continue; freq < 2 freq 2 continue; res += comb(freq) res comb(freq) comb freq System.out.println(res) System.out.println System.out System System.out res String args[] args private static long comb(long a) {
    	return a * (a - 1) / 2;
    } comb {
    	return a * (a - 1) / 2;
    } return a * (a - 1) / 2; a * (a - 1) / 2 a * (a - 1) a (a - 1) a 1 2 long a a public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    }

    private static long comb(long a) {
    	return a * (a - 1) / 2;
    }
} public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    }

    private static long comb(long a) {
    	return a * (a - 1) / 2;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> wordFreq = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	String word = sc.next();
        	char[] arr = word.toCharArray();
        	Arrays.sort(arr);
        	String newWord = new String(arr);
        	wordFreq.put(newWord, wordFreq.getOrDefault(newWord, 0) + 1);
        }
        long res = 0;
        for(Integer freq : wordFreq.values()) {
        	if(freq < 2) continue;
        	res += comb(freq);
        }
        System.out.println(res);
    }

    private static long comb(long a) {
    	return a * (a - 1) / 2;
    }
}
