import collections



N=int(eval(input()))

s=[[] for _ in range(N)]



for i in range(N):

    s[i]=eval(input())



p=101

ha=[0]*N

for i in range(N):

    for j in range(len(s[i])):

        ha[i]+=pow(p,(ord(s[i][j])-ord("a")))

c=collections.Counter(ha)



ans=0

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

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

print(ans)


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

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

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



def main():

    mod=10**9+7

    N=I()

    from collections import defaultdict

    dd = defaultdict(int)

    

    for _ in range(N):

        s=list(eval(input()))

        s.sort()

        s=''.join(map(str, s))

        dd[s]+=1

        

    ans=0

    

    for k,v in list(dd.items()):

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

        

    print(ans)



main()

import collections

N = int(eval(input()))
s = [[] for _ in range(N)]
for i in range(N):
    s[i] = eval(input())
p = 101
ha = [0] * N
for i in range(N):
    for j in range(len(s[i])):
        ha[i] += pow(p, (ord(s[i][j]) - ord("a")))
c = collections.Counter(ha)
ans = 0
for n in list(c.values()):
    ans += (n * (n - 1)) // 2
print(ans)

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


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


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


def main():
    mod = 10**9 + 7
    N = I()
    from collections import defaultdict

    dd = defaultdict(int)
    for _ in range(N):
        s = list(eval(input()))
        s.sort()
        s = "".join(map(str, s))
        dd[s] += 1
    ans = 0
    for k, v in list(dd.items()):
        ans += (v * (v - 1)) // 2
    print(ans)


main()

-import collections +def I(): +    return int(eval(input())) -N = int(eval(input())) -s = [[] for _ in range(N)] -for i in range(N): -    s[i] = eval(input()) -p = 101 -ha = [0] * N -for i in range(N): -    for j in range(len(s[i])): -        ha[i] += pow(p, (ord(s[i][j]) - ord("a"))) -c = collections.Counter(ha) -ans = 0 -for n in list(c.values()): -    ans += (n * (n - 1)) // 2 -print(ans) + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N = I() +    from collections import defaultdict + +    dd = defaultdict(int) +    for _ in range(N): +        s = list(eval(input())) +        s.sort() +        s = "".join(map(str, s)) +        dd[s] += 1 +    ans = 0 +    for k, v in list(dd.items()): +        ans += (v * (v - 1)) // 2 +    print(ans) + + +main()