def ccc(n):

    #c(n,2)

    result = (n * (n-1))//2

    return result







def sortString(a):

    a = list(a)

    a.sort()

    return "".join(a)





def calculate(arr):

    if len(arr) == 0:

        return 0



    dict = {}

    for i in range(len(arr)):

        s = sortString(arr[i])

        if dict.get(s) == None:

            dict.setdefault(s,1)

        else:

            dict.__setitem__(s,dict.get(s) + 1)





    sum = 0

    for v in list(dict.values()):

        sum += ccc(v)



    return sum







arr = []



N = int(eval(input()))

for i in range(N):

    arr.append(eval(input()))





result = calculate(arr)

print(result)
N = 3

SRR = [

    "acornistnt",

    "peanutbomb",

    "constraint",

]



N = 5

SRR = [

    "abaaaaaaaa",

    "oneplustwo",

    "aaaaaaaaba",

    "twoplusone",

    "aaaabaaaaa",

]



N = int(eval(input()))

SRR = []



for i in range(N):

    SRR.append(eval(input()))



def calculate(n,arr):

    dict = {}

    for i in range(n):

        str = "".join(sorted(list(arr[i])))

        if dict.get(str) == None:

            dict.__setitem__(str,1)

        else:

            dict.__setitem__(str,dict.get(str) + 1)



    result = 0



    for item in list(dict.values()):

        if item > 1:

            result += (item * (item-1)) // 2



    print(result)





calculate(N, SRR)
def ccc(n):
    # c(n,2)
    result = (n * (n - 1)) // 2
    return result


def sortString(a):
    a = list(a)
    a.sort()
    return "".join(a)


def calculate(arr):
    if len(arr) == 0:
        return 0
    dict = {}
    for i in range(len(arr)):
        s = sortString(arr[i])
        if dict.get(s) == None:
            dict.setdefault(s, 1)
        else:
            dict.__setitem__(s, dict.get(s) + 1)
    sum = 0
    for v in list(dict.values()):
        sum += ccc(v)
    return sum


arr = []
N = int(eval(input()))
for i in range(N):
    arr.append(eval(input()))
result = calculate(arr)
print(result)

N = 3
SRR = [
    "acornistnt",
    "peanutbomb",
    "constraint",
]
N = 5
SRR = [
    "abaaaaaaaa",
    "oneplustwo",
    "aaaaaaaaba",
    "twoplusone",
    "aaaabaaaaa",
]
N = int(eval(input()))
SRR = []
for i in range(N):
    SRR.append(eval(input()))


def calculate(n, arr):
    dict = {}
    for i in range(n):
        str = "".join(sorted(list(arr[i])))
        if dict.get(str) == None:
            dict.__setitem__(str, 1)
        else:
            dict.__setitem__(str, dict.get(str) + 1)
    result = 0
    for item in list(dict.values()):
        if item > 1:
            result += (item * (item - 1)) // 2
    print(result)


calculate(N, SRR)

-def ccc(n): -    # c(n,2) -    result = (n * (n - 1)) // 2 -    return result +N = 3 +SRR = [ +    "acornistnt", +    "peanutbomb", +    "constraint", +] +N = 5 +SRR = [ +    "abaaaaaaaa", +    "oneplustwo", +    "aaaaaaaaba", +    "twoplusone", +    "aaaabaaaaa", +] +N = int(eval(input())) +SRR = [] +for i in range(N): +    SRR.append(eval(input())) -def sortString(a): -    a = list(a) -    a.sort() -    return "".join(a) +def calculate(n, arr): +    dict = {} +    for i in range(n): +        str = "".join(sorted(list(arr[i]))) +        if dict.get(str) == None: +            dict.__setitem__(str, 1) +        else: +            dict.__setitem__(str, dict.get(str) + 1) +    result = 0 +    for item in list(dict.values()): +        if item > 1: +            result += (item * (item - 1)) // 2 +    print(result) -def calculate(arr): -    if len(arr) == 0: -        return 0 -    dict = {} -    for i in range(len(arr)): -        s = sortString(arr[i]) -        if dict.get(s) == None: -            dict.setdefault(s, 1) -        else: -            dict.__setitem__(s, dict.get(s) + 1) -    sum = 0 -    for v in list(dict.values()): -        sum += ccc(v) -    return sum - - -arr = [] -N = int(eval(input())) -for i in range(N): -    arr.append(eval(input())) -result = calculate(arr) -print(result) +calculate(N, SRR)