import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

} import java.util.*; util.* java import java.util.Map.Entry; Entry java.util.Map public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc HashMap<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        } {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        } char[] c = sc.next().toCharArray(); c sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Arrays.sort(c) Arrays.sort Arrays c String key = String.valueOf(c); key String.valueOf(c) String.valueOf String c if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            } map.containsKey(key) map.containsKey map key {
                map.put(key, map.get(key) + 1);
            } map.put(key, map.get(key) + 1) map.put map key map.get(key) + 1 map.get(key) map.get map key 1 {
                map.put(key, 1);
            } map.put(key, 1) map.put map key 1 long ans = 0; ans 0 for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        } Entry<String, Integer> e map.entrySet() map.entrySet map {
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        } {
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        } ans += (long)e.getValue() * (long)(e.getValue() -1) /2 ans (long)e.getValue() * (long)(e.getValue() -1) /2 (long)e.getValue() * (long)(e.getValue() -1) (long)e.getValue() e.getValue e (long)(e.getValue() -1) e.getValue() e.getValue e 1 2 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

} Main
import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

}
