import java.util.*;
public class Main{
	public static void main(String[] args){
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		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[] S = new String[N];
		for( int i=0; i<N; i++ ){
			S[i] = sc.next();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	} main {
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			S[i] = sc.next();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		} {
			S[i] = sc.next();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		} S[i] = sc.next() S[i] S i sc.next() sc.next sc String[] str = new String[10]; str new String[10] 10 for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			} int j=0; int j=0; j 0 j<10 j 10 j++ j++ j {
				str[j] = String.valueOf(S[i].charAt(j));
			} {
				str[j] = String.valueOf(S[i].charAt(j));
			} str[j] = String.valueOf(S[i].charAt(j)) str[j] str j String.valueOf(S[i].charAt(j)) String.valueOf String S[i].charAt(j) S[i].charAt S[i] S i j Arrays.sort(str) Arrays.sort Arrays str S[i] = "A" S[i] S i "A" for( int j=0; j<10; j++ ){
				S[i] += str[j];
			} int j=0; int j=0; j 0 j<10 j 10 j++ j++ j {
				S[i] += str[j];
			} {
				S[i] += str[j];
			} S[i] += str[j] S[i] S i str[j] str j 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++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				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++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		} {        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		} if( S[i].equals(S[i-1]) ){
				count++;
            } S[i].equals(S[i-1]) S[i].equals S[i] S i S[i-1] S i-1 i 1 {
				count++;
            } count++ count if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			} !(S[i].equals(S[i-1])) || i==N-1 !(S[i].equals(S[i-1])) (S[i].equals(S[i-1])) S[i].equals S[i] S i S[i-1] S i-1 i 1 i==N-1 i N-1 N 1 {           
				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 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[] S = new String[N];
		for( int i=0; i<N; i++ ){
			S[i] = sc.next();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args){
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	}
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
		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();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	}
}
