import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
} Main public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	} main {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	} InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out InputReader in = new InputReader(inputStream); in new InputReader(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) Task solver = new Task(); solver new Task() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	} Task public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		} solve {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		} int n = in.nextInt(); n in.nextInt() in.nextInt in String[] inputString = new String[n]; inputString new String[n] n for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			} int testcase = -1; int testcase = -1; testcase -1 1 ++ testcase < n ++ testcase testcase n {
				inputString[testcase] = sortString(in.next().toCharArray());
			} {
				inputString[testcase] = sortString(in.next().toCharArray());
			} inputString[testcase] = sortString(in.next().toCharArray()) inputString[testcase] inputString testcase sortString(in.next().toCharArray()) sortString in.next().toCharArray() in.next().toCharArray in.next() in.next in Arrays.sort(inputString) Arrays.sort Arrays inputString long res = 0 res 0 count = 1; count 1 for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			} int i = 0; int i = 0; i 0 ++i < n ++i i n {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			} {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			} if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				} !inputString[i].equals(inputString[i-1]) inputString[i].equals(inputString[i-1]) inputString[i].equals inputString[i] inputString i inputString[i-1] inputString i-1 i 1 {
					res+=count*(count-1)/2;
					count = 0;
					
				} res+=count*(count-1)/2 res count*(count-1)/2 count*(count-1) count (count-1) count 1 2 count = 0 count 0 ++count count out.print(res+count*(count-1)/2) out.print out res+count*(count-1)/2 res count*(count-1)/2 count*(count-1) count (count-1) count 1 2 int numTest numTest InputReader in in PrintWriter out out private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		} sortString {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		} Arrays.sort(charArray) Arrays.sort Arrays charArray return String.copyValueOf(charArray); String.copyValueOf(charArray) String.copyValueOf String charArray char[] charArray charArray static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	} InputReader public BufferedReader reader; reader public StringTokenizer tokenizer; tokenizer public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		} InputReader {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		} reader = new BufferedReader(new InputStreamReader(stream), 32768) reader new BufferedReader(new InputStreamReader(stream), 32768) tokenizer = null tokenizer null InputStream stream stream public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		} next {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		} while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			} tokenizer==null||!tokenizer.hasMoreTokens() tokenizer==null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			} try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				} catch (IOException e) {
					throw new RuntimeException(e);
				} IOException e {
					throw new RuntimeException(e);
				} throw new RuntimeException(e); new RuntimeException(e) {
					tokenizer = new StringTokenizer(reader.readLine());
				} tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
} public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task{
		public void solve(int numTest, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String[] inputString = new String[n];
			for(int testcase = -1; ++ testcase < n;) {
				inputString[testcase] = sortString(in.next().toCharArray());
			}
			Arrays.sort(inputString);
			 
			long res = 0, count = 1;
			for(int i = 0; ++i < n;) {
				if(!inputString[i].equals(inputString[i-1])) {
					res+=count*(count-1)/2;
					count = 0;
					
				}
				++count;
				
			}
			
			out.print(res+count*(count-1)/2);
		}

		private String sortString(char[] charArray) {
			Arrays.sort(charArray);
			return String.copyValueOf(charArray);
		}
	}
	
	
/*
5
4 5
2 1
3 2
2 5

*/				
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer==null||!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
	}
		
}