import 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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
} import java.util.*; util.* java 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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		} {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		} char[] sp = sc.next().toCharArray(); sp sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.parallelSort(sp) Arrays.parallelSort Arrays sp s[i] = String.valueOf(sp) s[i] s i String.valueOf(sp) String.valueOf String sp Arrays.parallelSort(s) Arrays.parallelSort Arrays s long ans = 0; ans 0 long cnt = 1; cnt 1 for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		} int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		} {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		} if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			} s[i].equals(s[i - 1]) s[i].equals s[i] s i s[i - 1] s i - 1 i 1 {
				cnt++;
			} cnt++ cnt {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			} ans += cnt * (cnt - 1) / 2 ans cnt * (cnt - 1) / 2 cnt * (cnt - 1) cnt (cnt - 1) cnt 1 2 cnt = 1 cnt 1 ans += cnt * (cnt - 1) / 2 ans cnt * (cnt - 1) / 2 cnt * (cnt - 1) cnt (cnt - 1) cnt 1 2 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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
} Main
import 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++) {
			char[] sp = sc.next().toCharArray();
			Arrays.parallelSort(sp);
			s[i] = String.valueOf(sp);
		}
		Arrays.parallelSort(s);
 
		long ans = 0;
		long cnt = 1;
		for (int i = 1; i < N; i++) {
			if (s[i].equals(s[i - 1])) {
				cnt++;
			} else {
				ans += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		ans += cnt * (cnt - 1) / 2;
		System.out.println(ans);
	}
}