import java.util.*;

public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
} import java.util.*; util.* java public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	} main {
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) final int NUM = scan.nextInt(); NUM scan.nextInt() scan.nextInt scan String[] words = new String[NUM]; words new String[NUM] NUM for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		} int i = 0; int i = 0; i 0 i < NUM i NUM i++ i++ i {
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		} {
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		} String input = scan.next(); input scan.next() scan.next scan char[] inputChar = input.toCharArray(); inputChar input.toCharArray() input.toCharArray input Arrays.sort(inputChar) Arrays.sort Arrays inputChar words[i] = new String(inputChar) words[i] words i new String(inputChar) Arrays.sort(words) Arrays.sort Arrays words String memory = words[0]; memory words[0] words 0 long count =1; count 1 long answer = 0; answer 0 for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		} int i = 1; int i = 1; i 1 i < NUM i NUM i++ i++ i {
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		} {
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		} if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			} memory.equals(words[i]) memory.equals memory words[i] words i {
				count++;
			} count++ count {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			} answer += count * (count - 1) / 2 answer count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 memory = words[i] memory words[i] words i count =1 count 1 if(count >= 2){
			answer += count * (count - 1) / 2;
		} count >= 2 count 2 {
			answer += count * (count - 1) / 2;
		} answer += count * (count - 1) / 2 answer count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
} public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
} Main
import java.util.*;

public class Main{
	

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		String[] words = new String[NUM];
		for(int i = 0; i < NUM; i++){
			String input = scan.next();
			char[] inputChar = input.toCharArray();
			Arrays.sort(inputChar);
			words[i] = new String(inputChar);
		}
		Arrays.sort(words);
		
		//check
		String memory = words[0];
		long count =1;
		long answer = 0;
		for(int i = 1; i < NUM; i++){
			if(memory.equals(words[i])){
				count++;
			} else {
				answer += count * (count - 1) / 2;
				memory = words[i];
				count =1;
			}
		}
		if(count >= 2){
			answer += count * (count - 1) / 2;
		}
		
		System.out.println(answer);
	}
}