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 scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-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 scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	}

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

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	} main {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner String[] S  = new String[N]; S new String[N] N Map<String, Integer> m=new HashMap<String, Integer>(); m new HashMap<String, Integer>() for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    } {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    } String s = scanner.next(); s scanner.next() scanner.next scanner char[] cs= s.toCharArray(); cs s.toCharArray() s.toCharArray s Arrays.parallelSort(cs) Arrays.parallelSort Arrays cs s = new String(cs) s new String(cs) if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        } m.containsKey(s) m.containsKey m s {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } int a = m.get(s); a m.get(s) m.get m s m.put(s, a+1) m.put m s a+1 a 1 {
	        	m.put(s, 1);
	        } m.put(s, 1) m.put m s 1 long r=0; r 0 for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    } Map.Entry<String, Integer> entry m.entrySet() m.entrySet m {
	        r+= f(entry.getValue());
	    } {
	        r+= f(entry.getValue());
	    } r+= f(entry.getValue()) r f(entry.getValue()) f entry.getValue() entry.getValue entry System.out.print(r) System.out.print System.out System System.out r String[] args args public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	} f {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	} if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		} n==1 n 1 {
			return 0;
		} return 0; 0 {
			return n-1 + f(n-1);
		} return n-1 + f(n-1); n-1 + f(n-1) n-1 n 1 f(n-1) f n-1 n 1 int n n public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	}

} public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-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 scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	}

}