def letternumber(S):

    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']

    s=[0 for i in range(0,26)]

    for i in range(0,10):

        s[alphabet.index(S[i])]+=1

    return s



def main():

    N=int(eval(input()))

    r=[]

    for i in range(0,N):

        r.append(letternumber(eval(input())))

    r.sort()

    s=1

    ans=0

    for i in range(0,N-1):

        if r[i]==r[i+1]:

            s=s+1

        else:

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

            s=1

    print((ans+s*(s-1)//2))



if __name__ == '__main__':

    main()




def main():

    N=int(eval(input()))

    r=[]

    for i in range(0,N):

        r.append(sorted(eval(input())))

    r.sort()

    s=1

    ans=0

    for i in range(0,N-1):

        if r[i]==r[i+1]:

            s=s+1

        else:

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

            s=1

    print((ans+s*(s-1)//2))



if __name__ == '__main__':

    main()

def letternumber(S):
    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",
    ]
    s = [0 for i in range(0, 26)]
    for i in range(0, 10):
        s[alphabet.index(S[i])] += 1
    return s


def main():
    N = int(eval(input()))
    r = []
    for i in range(0, N):
        r.append(letternumber(eval(input())))
    r.sort()
    s = 1
    ans = 0
    for i in range(0, N - 1):
        if r[i] == r[i + 1]:
            s = s + 1
        else:
            ans += s * (s - 1) // 2
            s = 1
    print((ans + s * (s - 1) // 2))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    r = []
    for i in range(0, N):
        r.append(sorted(eval(input())))
    r.sort()
    s = 1
    ans = 0
    for i in range(0, N - 1):
        if r[i] == r[i + 1]:
            s = s + 1
        else:
            ans += s * (s - 1) // 2
            s = 1
    print((ans + s * (s - 1) // 2))


if __name__ == "__main__":
    main()

-def letternumber(S): -    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", -    ] -    s = [0 for i in range(0, 26)] -    for i in range(0, 10): -        s[alphabet.index(S[i])] += 1 -    return s - - -        r.append(letternumber(eval(input()))) +        r.append(sorted(eval(input())))