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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Map.Entry; Entry java.util.Map 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();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in Map<String, Long> map = new HashMap<>(); map new HashMap<>() long cnt = 0; cnt 0 for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		} 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);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		} {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		} 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) if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			} map.containsKey(key) map.containsKey map key {
				map.put(key, map.get(key) + 1);
			} 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, (long) 1);
			} map.put(key, (long) 1) map.put map key (long) 1 for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		} Entry<String, Long> en map.entrySet() map.entrySet map {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		} {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		} cnt += nCr(en.getValue(), 2) cnt nCr(en.getValue(), 2) nCr en.getValue() en.getValue en 2 System.out.println(cnt) System.out.println System.out System System.out cnt in.close() in.close in String[] args args private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	} nCr {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	} if ( r == 0 ) return 1; r == 0 r 0 return 1; 1 return n * nCr(n - 1, r - 1) / r; n * nCr(n - 1, r - 1) / r n * nCr(n - 1, r - 1) n nCr(n - 1, r - 1) nCr n - 1 n 1 r - 1 r 1 r long n n long r r public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long cnt = 0;

		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);

			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			}else {
				map.put(key, (long) 1);
			}			
		}

		for ( Entry<String, Long> en : map.entrySet() ) {
			// System.out.println(en);
			cnt += nCr(en.getValue(), 2);
		}

		System.out.println(cnt);
		in.close();
	}
	
	private static long nCr(long n, long r) {
		if ( r == 0 ) return 1;
		return n * nCr(n - 1, r - 1) / r;
	}
}
