import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

} Main public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  } main {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  } int N; N Map<String,Long> groupMap; groupMap try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    } {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc groupMap = new HashMap<>() groupMap new HashMap<>() for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      } {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      } String ns = normed(sc.next()); ns normed(sc.next()) normed sc.next() sc.next sc Long count = groupMap.get(ns); count groupMap.get(ns) groupMap.get groupMap ns if ( count == null ) {
          count = 0L;
        } count == null count null {
          count = 0L;
        } count = 0L count 0L count++ count groupMap.put(ns, count) groupMap.put groupMap ns count long answer = 0; answer 0 for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    } Long count groupMap.values() groupMap.values groupMap {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    } {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    } if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      } count > 1 count 1 {
	    answer += count * (count - 1) / 2;
      } answer += count * (count - 1) / 2 answer count * (count - 1) / 2 count * (count - 1) count (count - 1) count 1 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  } normed {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  } if ( s == null ) {
      return null;
    } s == null s null {
      return null;
    } return null; null char[] ca = s.toCharArray(); ca s.toCharArray() s.toCharArray s Arrays.sort(ca) Arrays.sort Arrays ca return new String(ca); new String(ca) String s s public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

} public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

}