
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) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
} 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) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
} Main public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  } main {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Map<String, Long> map = new HashMap<String, Long>(); map new HashMap<String, Long>() for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    } {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    } String in = sc.next(); in sc.next() sc.next sc char[] chars = in.toCharArray(); chars in.toCharArray() in.toCharArray in Arrays.sort(chars) Arrays.sort Arrays chars String s = new String(chars); s new String(chars) Long p = map.get(s); p map.get(s) map.get map s if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      } p == null p null {
        map.put(s, 1L);
      } map.put(s, 1L) map.put map s 1L {
        map.put(s, p + 1);
      } map.put(s, p + 1) map.put map s p + 1 p 1 long cnt = 0; cnt 0 for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    } Map.Entry<String, Long> entry map.entrySet() map.entrySet map {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    } {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    } long i = entry.getValue(); i entry.getValue() entry.getValue entry if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      } i > 1 i 1 {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      } cnt += (i * (i - 1)) / 2 cnt (i * (i - 1)) / 2 (i * (i - 1)) i (i - 1) i 1 2 System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
} public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
} 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) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String, Long> map = new HashMap<String, Long>();

    for (int i = 0; i < n; i++) {
      String in = sc.next();
      char[] chars = in.toCharArray();
      Arrays.sort(chars);
      String s = new String(chars);

      Long p = map.get(s);
      if (p == null) {
        map.put(s, 1L);
      } else {
        map.put(s, p + 1);
      }
    }

    long cnt = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      if (i > 1) {
        // valueC2
        cnt += (i * (i - 1)) / 2;
      }
    }
    System.out.println(cnt);
  }
}
