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

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	} try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		} {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Map<String, Integer> countHash = new HashMap<>(); countHash new HashMap<>() for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			} {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			} String s = sc.next(); s sc.next() sc.next sc char[] chars = s.toCharArray(); chars s.toCharArray() s.toCharArray s Arrays.sort(chars) Arrays.sort Arrays chars String sorted_s = new String(chars); sorted_s new String(chars) int currentCount = 1; currentCount 1 if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				} countHash.containsKey(sorted_s) countHash.containsKey countHash sorted_s {
					currentCount = countHash.get(sorted_s) + 1;
				} currentCount = countHash.get(sorted_s) + 1 currentCount countHash.get(sorted_s) + 1 countHash.get(sorted_s) countHash.get countHash sorted_s 1 countHash.put(sorted_s, currentCount) countHash.put countHash sorted_s currentCount long answerCombination = 0; answerCombination 0 for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			} String key countHash.keySet() countHash.keySet countHash {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			} {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			} long count = (long)countHash.get(key); count (long)countHash.get(key) countHash.get countHash key if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				} count > 1 count 1 {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				} long combination = count * (count - 1) / 2; combination count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 answerCombination += combination answerCombination combination System.out.println(answerCombination) System.out.println System.out System System.out answerCombination String[] args args public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
} public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			
			Map<String, Integer> countHash = new HashMap<>(); 

			//sort strings a to z
			for( int i = 0 ; i < n ; i++ ) {
				String s = sc.next();
				char[] chars = s.toCharArray(); 
				Arrays.sort(chars);
				String sorted_s = new String(chars);
//				System.out.println(sorted_s);
				
				int currentCount = 1;
				if ( countHash.containsKey(sorted_s)) {
					currentCount = countHash.get(sorted_s) + 1;
				}
				countHash.put(sorted_s, currentCount);
			}
			
			long answerCombination = 0;
			for(String key : countHash.keySet()) {
				long count = (long)countHash.get(key);
				if ( count > 1 ) {
					//2 --> 2C2
					//3 --> 3C2
					//4 --> 4C2
					long combination = count * (count - 1) / 2; 
					answerCombination += combination;
				}
			}
			
			System.out.println(answerCombination);
			
		}
	}
}