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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc String s[] = new String[N]; s new String[N] N for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			s[i] = sc.next();
		} {
			s[i] = sc.next();
		} s[i] = sc.next() s[i] s i sc.next() sc.next sc String t[] = new String[N]; t new String[N] N for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		} {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		} char[] chars = s[i].toCharArray(); chars s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(chars) Arrays.sort Arrays chars t[i] = new String(chars) t[i] t i new String(chars) Arrays.sort(t) Arrays.sort Arrays t long ans = 0; ans 0 int tmp = 0; tmp 0 for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		} int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		} {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		} if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			} t[i].equals(t[i + 1]) t[i].equals t[i] t i t[i + 1] t i + 1 i 1 {
				tmp++;
			} tmp++ tmp {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			} ans += ((long)(tmp+1)*tmp)/2 ans ((long)(tmp+1)*tmp)/2 ((long)(tmp+1)*tmp) (long)(tmp+1) tmp 1 tmp 2 tmp = 0 tmp 0 ans += ((long)(tmp+1)*tmp)/2 ans ((long)(tmp+1)*tmp)/2 ((long)(tmp+1)*tmp) (long)(tmp+1) tmp 1 tmp 2 tmp = 0 tmp 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
} Main

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
}