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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	}
	public static void p(Object o) {
		System.out.println(o);
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	}
	public static void p(Object o) {
		System.out.println(o);
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	} main {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int N=sc.nextInt(); N sc.nextInt() sc.nextInt sc HashMap<String,Long> gram=new HashMap(); gram new HashMap() long ans=0L; ans 0L for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		} {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		} String s=sc.next(); s sc.next() sc.next sc char[] c=new char[s.length()]; c new char[s.length()] s.length() s.length s c=s.toCharArray() c s.toCharArray() s.toCharArray s Arrays.sort(c) Arrays.sort Arrays c String s2=String.valueOf(c); s2 String.valueOf(c) String.valueOf String c if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			} gram.containsKey(s2) gram.containsKey gram s2 {
				gram.put(s2,gram.get(s2)+1L);
			} gram.put(s2,gram.get(s2)+1L) gram.put gram s2 gram.get(s2)+1L gram.get(s2) gram.get gram s2 1L {
				gram.put(s2,1L);
			} gram.put(s2,1L) gram.put gram s2 1L for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		} long num gram.values() gram.values gram {
			ans+=(num-1)*num/2L;
		} {
			ans+=(num-1)*num/2L;
		} ans+=(num-1)*num/2L ans (num-1)*num/2L (num-1)*num (num-1) num 1 num 2L p(ans) p ans String[] args args public static void p(Object o) {
		System.out.println(o);
	} p {
		System.out.println(o);
	} System.out.println(o) System.out.println System.out System System.out o Object o o
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		HashMap<String,Long> gram=new HashMap();
		long ans=0L;
		for(int i=0; i<N; i++) {
			String s=sc.next();
			char[] c=new char[s.length()];
			c=s.toCharArray();
			Arrays.sort(c);
			String s2=String.valueOf(c);
			if(gram.containsKey(s2)) {
				gram.put(s2,gram.get(s2)+1L);
			}
			else {
				gram.put(s2,1L);
			}
		}

		for(long num : gram.values()) {
			ans+=(num-1)*num/2L;
		}
		p(ans);

	}
	public static void p(Object o) {
		System.out.println(o);
	}
}