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

public class Main {

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

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	}

} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap 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 = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	}

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

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	} main {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc String stmp; stmp int idx; idx HashMap<String, Long> sMap = new HashMap<String, Long>(); sMap new HashMap<String, Long>() Long num = 0L; num 0L String s; s for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		} idx = 0; idx = 0 idx 0 idx < N idx N idx++ idx++ idx {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		} {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		} stmp = sc.next() stmp sc.next() sc.next sc char[] c1 = stmp.toCharArray(); c1 stmp.toCharArray() stmp.toCharArray stmp Arrays.sort(c1) Arrays.sort Arrays c1 s = String.valueOf(c1) s String.valueOf(c1) String.valueOf String c1 num = sMap.get(s) num sMap.get(s) sMap.get sMap s if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			} num == null num null {
				sMap.put(s, 1L);
			} sMap.put(s, 1L) sMap.put sMap s 1L {
				sMap.put(s, num + 1);
			} sMap.put(s, num + 1) sMap.put sMap s num + 1 num 1 long match = 0; match 0 ArrayList<Long> numList = new ArrayList<>(sMap.values()); numList new ArrayList<>(sMap.values()) for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		} Long nums numList {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		} {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		} if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			} nums > 1 nums 1 {
				match += (nums * (nums-1L)) / 2L;
			} match += (nums * (nums-1L)) / 2L match (nums * (nums-1L)) / 2L (nums * (nums-1L)) nums (nums-1L) nums 1L 2L System.out.println(match) System.out.println System.out System System.out match String[] args args public class Main {

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

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	}

} public class Main {

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

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	}

} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		int N = Integer.parseInt(sc.next());
		String stmp;
		int idx;
		HashMap<String, Long> sMap = new HashMap<String, Long>();

		Long num = 0L;
		String s;

		for (idx = 0; idx < N; idx++) {
			stmp = sc.next();
			char[] c1 = stmp.toCharArray();
			Arrays.sort(c1);
			s = String.valueOf(c1);

			num = sMap.get(s);
			if (num == null) {
				sMap.put(s, 1L);
			} else {
				sMap.put(s, num + 1);
			}
		}

		long match = 0;
		ArrayList<Long> numList = new ArrayList<>(sMap.values());
		for (Long nums : numList) {
			if (nums > 1) {
				match += (nums * (nums-1L)) / 2L;
			}
		}

		System.out.println(match);

	}

}
