import sys 

from collections import Counter

from math import factorial



def combinations_count(n, r):

  return factorial(n) // (factorial(n - r) * factorial(r))

 

def main():

  input = sys.stdin.readline

  N = int(eval(input()))

  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]

  c = Counter(texts)

  cnt = 0

  for t in list(c.values()):

    if t > 1:

      cnt += combinations_count(t, 2)

  print(cnt)

 

if __name__ == '__main__':

  main()

import sys 

from collections import Counter



def main():

  input = sys.stdin.readline

  N = int(eval(input()))

  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]

  c = Counter(texts)

  cnt = 0

  for t in list(c.values()):

    if t > 1:

      cnt += (t * (t-1)) // 2

  print(cnt)

 

if __name__ == '__main__':

  main()

import sys
from collections import Counter
from math import factorial


def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    texts = ["".join(sorted(list(input().rstrip()))) for _ in range(N)]
    c = Counter(texts)
    cnt = 0
    for t in list(c.values()):
        if t > 1:
            cnt += combinations_count(t, 2)
    print(cnt)


if __name__ == "__main__":
    main()

import sys
from collections import Counter


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    texts = ["".join(sorted(list(input().rstrip()))) for _ in range(N)]
    c = Counter(texts)
    cnt = 0
    for t in list(c.values()):
        if t > 1:
            cnt += (t * (t - 1)) // 2
    print(cnt)


if __name__ == "__main__":
    main()

-from math import factorial - - -def combinations_count(n, r): -    return factorial(n) // (factorial(n - r) * factorial(r)) -            cnt += combinations_count(t, 2) +            cnt += (t * (t - 1)) // 2