from collections import defaultdict

from collections import deque

from collections import Counter

import itertools

import math



def readInt():

  return int(eval(input()))

def readInts():

  return list(map(int, input().split()))

def readChar():

  return eval(input())

def readChars():

  return input().split()



def comb(n,r):

  return math.factorial(n)//math.factorial(r)//math.factorial(max(1,n-r))



def con(t):

  ans = ""

  for i in t:

    ans+=i[0]+str(i[1])

  return ans



n = readInt()

d = defaultdict(int)

for i in [eval(input()) for i in range(n)]:

  t = defaultdict(int)

  for j in i:

    t[j]+=1

  d[con(sorted(t.items()))]+=1

ans = 0

for i in d:

  ans+=comb(d[i],2)



print(ans)
from collections import defaultdict

from collections import deque

from collections import Counter

import itertools

import math



def readInt():

  return int(eval(input()))

def readInts():

  return list(map(int, input().split()))

def readChar():

  return eval(input())

def readChars():

  return input().split()



n = readInt()

d = defaultdict(int)

for i in [eval(input()) for j in range(n)]:

  d["".join(sorted(i))]+=1



from math import factorial as f



ans = 0

for i in d:

  if d[i]>1:

    ans+=f(d[i])//f(2)//f(d[i]-2)



print(ans)
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math


def readInt():
    return int(eval(input()))


def readInts():
    return list(map(int, input().split()))


def readChar():
    return eval(input())


def readChars():
    return input().split()


def comb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(max(1, n - r))


def con(t):
    ans = ""
    for i in t:
        ans += i[0] + str(i[1])
    return ans


n = readInt()
d = defaultdict(int)
for i in [eval(input()) for i in range(n)]:
    t = defaultdict(int)
    for j in i:
        t[j] += 1
    d[con(sorted(t.items()))] += 1
ans = 0
for i in d:
    ans += comb(d[i], 2)
print(ans)

from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math


def readInt():
    return int(eval(input()))


def readInts():
    return list(map(int, input().split()))


def readChar():
    return eval(input())


def readChars():
    return input().split()


n = readInt()
d = defaultdict(int)
for i in [eval(input()) for j in range(n)]:
    d["".join(sorted(i))] += 1
from math import factorial as f

ans = 0
for i in d:
    if d[i] > 1:
        ans += f(d[i]) // f(2) // f(d[i] - 2)
print(ans)

-def comb(n, r): -    return math.factorial(n) // math.factorial(r) // math.factorial(max(1, n - r)) - - -def con(t): -    ans = "" -    for i in t: -        ans += i[0] + str(i[1]) -    return ans - - -for i in [eval(input()) for i in range(n)]: -    t = defaultdict(int) -    for j in i: -        t[j] += 1 -    d[con(sorted(t.items()))] += 1 +for i in [eval(input()) for j in range(n)]: +    d["".join(sorted(i))] += 1 +from math import factorial as f + -    ans += comb(d[i], 2) +    if d[i] > 1: +        ans += f(d[i]) // f(2) // f(d[i] - 2)