import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		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[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-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[] strs = new String[n]; strs new String[n] n for(int i=0; i<n; i++){
			strs[i] = sc.next();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			strs[i] = sc.next();
		} {
			strs[i] = sc.next();
		} strs[i] = sc.next() strs[i] strs i sc.next() sc.next sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		} String str strs {
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		} {
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		} char[] chs = new char[str.length()]; chs new char[str.length()] str.length() str.length str for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				chs[i] = str.charAt(i);
			} {
				chs[i] = str.charAt(i);
			} chs[i] = str.charAt(i) chs[i] chs i str.charAt(i) str.charAt str i Arrays.sort(chs) Arrays.sort Arrays chs String sorted = new String(chs); sorted new String(chs) Integer count = map.get(sorted); count map.get(sorted) map.get map sorted if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			} count == null count null {
				map.put(sorted, 1);
			} map.put(sorted, 1) map.put map sorted 1 {
				map.put(sorted, count+1);
			} map.put(sorted, count+1) map.put map sorted count+1 count 1 long ans = 0; ans 0 for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		} long i map.values() map.values map {
			if(i>1){
				ans += i*(i-1)/2;
			}
		} {
			if(i>1){
				ans += i*(i-1)/2;
			}
		} if(i>1){
				ans += i*(i-1)/2;
			} i>1 i 1 {
				ans += i*(i-1)/2;
			} ans += i*(i-1)/2 ans i*(i-1)/2 i*(i-1) i (i-1) i 1 2 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[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		System.out.println(ans);
	}
} public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		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[] strs = new String[n];
		for(int i=0; i<n; i++){
			strs[i] = sc.next();
		}
		Map<String, Integer> map = new HashMap<>();
		for(String str: strs){
			char[] chs = new char[str.length()];
			for(int i=0; i<str.length(); i++){
				chs[i] = str.charAt(i);
			}
			Arrays.sort(chs);
			String sorted = new String(chs);
			Integer count = map.get(sorted);
			if(count == null) {
				map.put(sorted, 1);
			} else {
				map.put(sorted, count+1);
			}
		}
		long ans = 0;
		for (long i : map.values()) {
			if(i>1){
				ans += i*(i-1)/2;
			}
		}
		System.out.println(ans);
	}
}
