import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	}
	
}

	class Data{
		  private int a;
		    private int b;
		    public Data(int a, int b) {
		        this.a = a;
		        this.b = b;
		    }
		    public int getA() {
		        return a;
		    }
		    public int getB() {
		        return b;
		    }
}

	class MyComparator implements Comparator {
		 
	    public int compare(Object obj1, Object obj2) {
	         
	        int num1 = (int)obj1;
	        int num2 = (int)obj2;
	         
	        if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        }
	    }
	}

 import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	}
	
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	} main {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-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++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		} {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		} s[i]=sc.next() s[i] s i sc.next() sc.next sc char[] c =s[i].toCharArray(); c s[i].toCharArray() s[i].toCharArray s[i] s i Arrays.sort(c) Arrays.sort Arrays c s[i]=new String(c) s[i] s i new String(c) Arrays.sort(s) Arrays.sort Arrays s long ans =0; ans 0 long count=1; count 1 for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		} {
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		} if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			} s[i].equals(s[i-1]) s[i].equals s[i] s i s[i-1] s i-1 i 1 {
				count++;
			} count++ count {
				ans+=count*(count-1)/2;
				count=1;
			} ans+=count*(count-1)/2 ans count*(count-1)/2 count*(count-1) count (count-1) count 1 2 count=1 count 1 ans+=count*(count-1)/2 ans count*(count-1)/2 count*(count-1) count (count-1) count 1 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args class Data{
		  private int a;
		    private int b;
		    public Data(int a, int b) {
		        this.a = a;
		        this.b = b;
		    }
		    public int getA() {
		        return a;
		    }
		    public int getB() {
		        return b;
		    }
} Data private int a; a private int b; b public Data(int a, int b) {
		        this.a = a;
		        this.b = b;
		    } Data {
		        this.a = a;
		        this.b = b;
		    } this.a = a this.a this this.a a this.b = b this.b this this.b b int a a int b b public int getA() {
		        return a;
		    } getA {
		        return a;
		    } return a; a public int getB() {
		        return b;
		    } getB {
		        return b;
		    } return b; b class MyComparator implements Comparator {
		 
	    public int compare(Object obj1, Object obj2) {
	         
	        int num1 = (int)obj1;
	        int num2 = (int)obj2;
	         
	        if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        }
	    }
	} MyComparator public int compare(Object obj1, Object obj2) {
	         
	        int num1 = (int)obj1;
	        int num2 = (int)obj2;
	         
	        if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        }
	    } compare {
	         
	        int num1 = (int)obj1;
	        int num2 = (int)obj2;
	         
	        if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        }
	    } int num1 = (int)obj1; num1 (int)obj1 int num2 = (int)obj2; num2 (int)obj2 if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        } num1 < num2 num1 num2 {
	            return 1;
	        } return 1; 1 if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        } num1 > num2 num1 num2 {
	            return -1;
	        } return -1; -1 1 {
	            return 0;
	        } return 0; 0 Object obj1 obj1 Object obj2 obj2 Comparator public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	}
	
} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	}
	
} Main
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		String s[]=new String[n];
		
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			char[] c =s[i].toCharArray();
			Arrays.sort(c);
			s[i]=new String(c);
		}
		
		Arrays.sort(s);
		
		long ans =0;
		long count=1;
		
		for(int i=1;i<n;i++){
			if(s[i].equals(s[i-1])) {
				count++;
			}
			else {
				ans+=count*(count-1)/2;
				count=1;
			}
			
		}
		ans+=count*(count-1)/2;
		
        System.out.println(ans);
	}
	
}

	class Data{
		  private int a;
		    private int b;
		    public Data(int a, int b) {
		        this.a = a;
		        this.b = b;
		    }
		    public int getA() {
		        return a;
		    }
		    public int getB() {
		        return b;
		    }
}

	class MyComparator implements Comparator {
		 
	    public int compare(Object obj1, Object obj2) {
	         
	        int num1 = (int)obj1;
	        int num2 = (int)obj2;
	         
	        if(num1 < num2) {
	            return 1;
	        } else if(num1 > num2) {
	            return -1;
	        } else{
	            return 0;
	        }
	    }
	}


