n=int(eval(input()))

A={}

for i in range(n):

  s=str(sorted(eval(input())))

  if s in list(A.keys()):

    A[s]+=1

  else:

    A[s]=1

ans=0

for i in list(A.values()):

  ans+=int(i*(i-1)/2)

print(ans)
def resolve():

    n=int(eval(input()))

    s={}

    for i in range(n):

        x=str(sorted(list(eval(input()))))

        if x in list(s.keys()):

            s[x]+=1

        else:

            s[x]=1

    ans=0

    if s:

        for i in list(s.values()):

            ans+=i*(i-1)//2

    print(ans)



if __name__ == '__main__':

    resolve()
n = int(eval(input()))
A = {}
for i in range(n):
    s = str(sorted(eval(input())))
    if s in list(A.keys()):
        A[s] += 1
    else:
        A[s] = 1
ans = 0
for i in list(A.values()):
    ans += int(i * (i - 1) / 2)
print(ans)

def resolve():
    n = int(eval(input()))
    s = {}
    for i in range(n):
        x = str(sorted(list(eval(input()))))
        if x in list(s.keys()):
            s[x] += 1
        else:
            s[x] = 1
    ans = 0
    if s:
        for i in list(s.values()):
            ans += i * (i - 1) // 2
    print(ans)


if __name__ == "__main__":
    resolve()

-n = int(eval(input())) -A = {} -for i in range(n): -    s = str(sorted(eval(input()))) -    if s in list(A.keys()): -        A[s] += 1 -    else: -        A[s] = 1 -ans = 0 -for i in list(A.values()): -    ans += int(i * (i - 1) / 2) -print(ans) +def resolve(): +    n = int(eval(input())) +    s = {} +    for i in range(n): +        x = str(sorted(list(eval(input())))) +        if x in list(s.keys()): +            s[x] += 1 +        else: +            s[x] = 1 +    ans = 0 +    if s: +        for i in list(s.values()): +            ans += i * (i - 1) // 2 +    print(ans) + + +if __name__ == "__main__": +    resolve()