//package atcoder;

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			String A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-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 A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			}
			System.out.println(ans);
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			String A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			}
			System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			String A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-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 A[] = new String[N]; A new String[N] N for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			} int i=0; int i=0; i 0 i<N i N i++ i++ i {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			} {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			} char B[] = new char[10]; B new char[10] 10 B = sc.next().toCharArray() B sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(B) Arrays.sort Arrays B A[i] = new String(B) A[i] A i new String(B) HashMap<String,Integer>map = new HashMap<String,Integer>(); map new HashMap<String,Integer>() long ans = 0; ans 0 for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			} int i=0; int i=0; i 0 i<N i N i++ i++ i {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			} {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			} if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				} map.containsKey(A[i]) map.containsKey map A[i] A i {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				} map.put(A[i],map.get(A[i])+1) map.put map A[i] A i map.get(A[i])+1 map.get(A[i]) map.get map A[i] A i 1 {
					map.put(A[i],1);
				} map.put(A[i],1) map.put map A[i] A i 1 for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			} String key map.keySet() map.keySet map {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			} {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			} long tmp = map.get(key); tmp map.get(key) map.get map key if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				} tmp>1 tmp 1 {
					ans += (tmp*(tmp-1)/2);
				} ans += (tmp*(tmp-1)/2) ans (tmp*(tmp-1)/2) tmp*(tmp-1) tmp (tmp-1) tmp 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 A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-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 A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			}
			System.out.println(ans);
	}
	
} Main
//package atcoder;

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			String A[] = new String[N];
			for(int i=0;i<N;i++) {
				char B[] = new char[10];
				B = sc.next().toCharArray();
				Arrays.sort(B);
				A[i] = new String(B);
				//System.out.println(A[i]);
			}
			HashMap<String,Integer>map = new HashMap<String,Integer>();
			long ans = 0;
			//System.out.println(map.get(A[0]));
			for(int i=0;i<N;i++) {
				if(map.containsKey(A[i])) {
					map.put(A[i],map.get(A[i])+1);
					//System.out.println(map.get(A[i]));
				}else {
					map.put(A[i],1);
				}
			}
		for(String key : map.keySet()) {
				long tmp = map.get(key);
				if(tmp>1) {
					ans += (tmp*(tmp-1)/2);
				}
			}
			System.out.println(ans);
	}
	
}