import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	}
	
	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}
	
	private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	}
	
	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}
	
	private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	} main {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		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> cnt = new HashMap<>(); cnt new HashMap<>() for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		} int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		} {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		} String s = sorted(in.next()); s sorted(in.next()) sorted in.next() in.next in cnt.put(s, cnt.getOrDefault(s, 0) + 1) cnt.put cnt s cnt.getOrDefault(s, 0) + 1 cnt.getOrDefault(s, 0) cnt.getOrDefault cnt s 0 1 long ans = 0; ans 0 for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		} String s cnt.keySet() cnt.keySet cnt {
			ans += nc2(cnt.get(s));
		} {
			ans += nc2(cnt.get(s));
		} ans += nc2(cnt.get(s)) ans nc2(cnt.get(s)) nc2 cnt.get(s) cnt.get cnt s System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	} nc2 {
		return (x * (x - 1)) >> 1;
	} return (x * (x - 1)) >> 1; (x * (x - 1)) >> 1 (x * (x - 1)) x (x - 1) x 1 1 long x x private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	} sorted {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	} char[] arr = s.toCharArray(); arr s.toCharArray() s.toCharArray s Arrays.sort(arr) Arrays.sort Arrays arr return new String(arr); new String(arr) String s s public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	}
	
	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}
	
	private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	}
	
	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}
	
	private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		HashMap<String, Integer> cnt = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			String s = sorted(in.next());
			cnt.put(s, cnt.getOrDefault(s, 0) + 1);
		}
		
		long ans = 0;
		for (String s : cnt.keySet()) {
			ans += nc2(cnt.get(s));
		}
		
		System.out.println(ans);
	}
	
	private static long nc2(long x) {
		return (x * (x - 1)) >> 1;
	}
	
	private static String sorted(String s) {
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		return new String(arr);
	}
}