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

public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} Main private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	} solve {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in HashMap<String, Integer> anagCount = new HashMap<>(); anagCount new HashMap<>() for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		} {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		} String s = in.next(); s in.next() in.next in char[] chars = s.toCharArray(); chars s.toCharArray() s.toCharArray s Arrays.sort(chars) Arrays.sort Arrays chars String sorted = new String(chars); sorted new String(chars) if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			} anagCount.containsKey(sorted) anagCount.containsKey anagCount sorted {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			} anagCount.put(sorted, anagCount.get(sorted)+1) anagCount.put anagCount sorted anagCount.get(sorted)+1 anagCount.get(sorted) anagCount.get anagCount sorted 1 {
				anagCount.put(sorted, 1);
			} anagCount.put(sorted, 1) anagCount.put anagCount sorted 1 long ans = 0; ans 0 for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		} int count anagCount.values() anagCount.values anagCount {
			ans += ((long)count)*(count-1)/2;
		} {
			ans += ((long)count)*(count-1)/2;
		} ans += ((long)count)*(count-1)/2 ans ((long)count)*(count-1)/2 ((long)count)*(count-1) ((long)count) (count-1) count 1 2 System.out.println(ans) System.out.println System.out System System.out ans public static void main(String[] args) {
		new Main().solve();
	} main {
		new Main().solve();
	} new Main().solve() new Main().solve new Main() String[] args args public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> anagCount = new HashMap<>();
		for(int i=0; i<N; i++) {
			String s = in.next();
			char[] chars = s.toCharArray();
			Arrays.sort(chars);
			String sorted = new String(chars);
			if(anagCount.containsKey(sorted)) {
				anagCount.put(sorted, anagCount.get(sorted)+1);
			}else {
				anagCount.put(sorted, 1);
			}
		}
		
		long ans = 0;
		for (int count : anagCount.values()) {
			ans += ((long)count)*(count-1)/2;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}
