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

public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	
	
	public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	}

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

} Main static Scanner scan = new Scanner(System.in); scan new Scanner(System.in) static HashMap<String, Integer> map = new HashMap<String, Integer>(); map new HashMap<String, Integer>() public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	} main {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	} int n  = scan.nextInt(); n scan.nextInt() scan.nextInt scan for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		} {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		} String s = scan.next(); s scan.next() scan.next scan char[] ca = s.toCharArray(); ca s.toCharArray() s.toCharArray s Arrays.sort(ca) Arrays.sort Arrays ca s = new String(ca) s new String(ca) if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			} map.containsKey(s) map.containsKey map s {
				map.put(s, map.get(s)+1);
			} map.put(s, map.get(s)+1) map.put map s map.get(s)+1 map.get(s) map.get map s 1 {
				map.put(s, 1);
			} map.put(s, 1) map.put map s 1 long sum = 0; sum 0 for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		} long k map.values() map.values map {
			k--;
			sum += (k*k+k)/2;
		} {
			k--;
			sum += (k*k+k)/2;
		} k-- k sum += (k*k+k)/2 sum (k*k+k)/2 (k*k+k) k*k k k k 2 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	
	
	public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	}

} public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	
	
	public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	}

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

public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	
	
	public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	}

}
