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) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
    static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    }
}
 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) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
    static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    }
} Main public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    } main {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long ans = 0; ans 0 Map<String, Integer> mMap = new HashMap<String, Integer>(); mMap new HashMap<String, Integer>() Map<String, Integer> mstr = new HashMap<String, Integer>(); mstr new HashMap<String, Integer>() for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		} int i = 0; int i = 0; i 0 i < N i N i ++ i ++ i {
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		} {
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		} String str = sc.next(); str sc.next() sc.next sc String[] strArray = str.split(""); strArray str.split("") str.split str "" Arrays.sort(strArray) Arrays.sort Arrays strArray String work = ""; work "" for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			} int j = 0; int j = 0; j 0 j < strArray.length j strArray.length strArray strArray.length j++ j++ j {
	        	work = work + strArray[j];
			} {
	        	work = work + strArray[j];
			} work = work + strArray[j] work work + strArray[j] work strArray[j] strArray j if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        } mMap.containsKey(work) mMap.containsKey mMap work {
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        } mMap.put( work,mMap.get(work) + 1) mMap.put mMap work mMap.get(work) + 1 mMap.get(work) mMap.get mMap work 1 ans = ans + mMap.get(work) ans ans + mMap.get(work) ans mMap.get(work) mMap.get mMap work {
	        	mMap.put( work,0);
	        } mMap.put( work,0) mMap.put mMap work 0 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc return ; String[] args args static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    } Factorial {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    } if (i == 0) {return 1;} i == 0 i 0 {return 1;} return 1; 1 if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	} i == 1 i 1 {
    		return 1;
    	} return 1; 1 {
    		return (i * Factorial(i-1));
    	} return (i * Factorial(i-1)); (i * Factorial(i-1)) i Factorial(i-1) Factorial i-1 i 1 int i i public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
    static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    }
} public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
    static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    }
} 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) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0;

		// Mapの宣言
        Map<String, Integer> mMap = new HashMap<String, Integer>();
		// Mapの宣言
        Map<String, Integer> mstr = new HashMap<String, Integer>();
        
		for (int i = 0; i < N;i ++ ){
			// 文字列の入力
			String str = sc.next();

			String[] strArray = str.split("");
			 
//			// ソートする
			Arrays.sort(strArray);
	        String work = "";
			for (int j = 0; j < strArray.length; j++) {
	        	work = work + strArray[j];
			}

	        if(mMap.containsKey(work)){
	        	mMap.put( work,mMap.get(work) + 1);
	        	ans = ans + mMap.get(work);
	        }else {
	        	mMap.put( work,0);
	        }
		}

//        Object[] mapkey = mMap.keySet().toArray();
//        for (Object nKey : mapkey)
//        {
//        	if(mMap.get(nKey)>1) {
//                ans = ans + ( Factorial(mMap.get(nKey)) / 2 * Factorial((mMap.get(nKey) - 2)) );
//        	}
//        }

		
		System.out.println(ans);

   		sc.close();
        return ;

    }
    
    static long Factorial (int i) {
    	if (i == 0) {return 1;}

    	if (i == 1) {
    		return 1;
    	}else {
    		return (i * Factorial(i-1));
    	}
    }
}

