N = int(eval(input()))

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

alphanum = dict()

for i in range(26): alphanum[alphabet[i]] = i



fact = [0] * (N + 1)

for i in range(1, N + 1): fact[i] = fact[i-1] + i



wordtype = dict()

for _ in range(N):

    s = eval(input())

    s_num = [0] * 26

    for i in range(len(s)):

        s_num[alphanum[s[i]]] += 1

    s_str = ""

    for i in range(26):

        s_str += alphabet[i] + str(s_num[i])

    

    if s_str in wordtype: wordtype[s_str] += 1

    else: wordtype[s_str] = 1



ans = 0

for key in wordtype:

    ans += fact[wordtype[key] - 1]



print(ans)

import sys



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    S = [list(input().strip("\n")) for _ in range(N)]

    for i in range(N): S[i].sort()

    S.sort()

    S.append(["E", "N", "D"])



    ans = 0

    current = "".join(S[0])

    same = 0

    for i in range(1, N+1):

        tempS = "".join(S[i])

        if tempS == current:

            same += 1

        else:

            ans += (1 + same) * same // 2

            same = 0

            current = tempS

    print(ans)



    return  0



if __name__ == "__main__":

    solve()
N = int(eval(input()))
alphabet = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
]
alphanum = dict()
for i in range(26):
    alphanum[alphabet[i]] = i
fact = [0] * (N + 1)
for i in range(1, N + 1):
    fact[i] = fact[i - 1] + i
wordtype = dict()
for _ in range(N):
    s = eval(input())
    s_num = [0] * 26
    for i in range(len(s)):
        s_num[alphanum[s[i]]] += 1
    s_str = ""
    for i in range(26):
        s_str += alphabet[i] + str(s_num[i])
    if s_str in wordtype:
        wordtype[s_str] += 1
    else:
        wordtype[s_str] = 1
ans = 0
for key in wordtype:
    ans += fact[wordtype[key] - 1]
print(ans)

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    S = [list(input().strip("\n")) for _ in range(N)]
    for i in range(N):
        S[i].sort()
    S.sort()
    S.append(["E", "N", "D"])
    ans = 0
    current = "".join(S[0])
    same = 0
    for i in range(1, N + 1):
        tempS = "".join(S[i])
        if tempS == current:
            same += 1
        else:
            ans += (1 + same) * same // 2
            same = 0
            current = tempS
    print(ans)
    return 0


if __name__ == "__main__":
    solve()

-N = int(eval(input())) -alphabet = [ -    "a", -    "b", -    "c", -    "d", -    "e", -    "f", -    "g", -    "h", -    "i", -    "j", -    "k", -    "l", -    "m", -    "n", -    "o", -    "p", -    "q", -    "r", -    "s", -    "t", -    "u", -    "v", -    "w", -    "x", -    "y", -    "z", -] -alphanum = dict() -for i in range(26): -    alphanum[alphabet[i]] = i -fact = [0] * (N + 1) -for i in range(1, N + 1): -    fact[i] = fact[i - 1] + i -wordtype = dict() -for _ in range(N): -    s = eval(input()) -    s_num = [0] * 26 -    for i in range(len(s)): -        s_num[alphanum[s[i]]] += 1 -    s_str = "" -    for i in range(26): -        s_str += alphabet[i] + str(s_num[i]) -    if s_str in wordtype: -        wordtype[s_str] += 1 -    else: -        wordtype[s_str] = 1 -ans = 0 -for key in wordtype: -    ans += fact[wordtype[key] - 1] -print(ans) +import sys + + +def solve(): +    input = sys.stdin.readline +    N = int(eval(input())) +    S = [list(input().strip("\n")) for _ in range(N)] +    for i in range(N): +        S[i].sort() +    S.sort() +    S.append(["E", "N", "D"]) +    ans = 0 +    current = "".join(S[0]) +    same = 0 +    for i in range(1, N + 1): +        tempS = "".join(S[i]) +        if tempS == current: +            same += 1 +        else: +            ans += (1 + same) * same // 2 +            same = 0 +            current = tempS +    print(ans) +    return 0 + + +if __name__ == "__main__": +    solve()