import math





def combinations_count(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))





def main():

    n = int(eval(input()))

    d = {}

    ans = 0

    

    for _ in range(n):

        ss = ''.join(sorted(eval(input())))

        d[ss] = d.get(ss, 0) + 1

        

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

        if v != 1:

            ans += combinations_count(v, 2)

         

    print(ans)

       

    

if __name__ == '__main__':

    main()
def main():

    n = int(eval(input()))

    d = {}

    ans = 0

    

    for _ in range(n):

        ss = ''.join(sorted(eval(input())))

        d[ss] = d.get(ss, 0) + 1

        

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

        if v != 1:

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

         

    print(ans)

       

    

if __name__ == '__main__':

    main()
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    n = int(eval(input()))
    d = {}
    ans = 0
    for _ in range(n):
        ss = "".join(sorted(eval(input())))
        d[ss] = d.get(ss, 0) + 1
    for k, v in list(d.items()):
        if v != 1:
            ans += combinations_count(v, 2)
    print(ans)


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    d = {}
    ans = 0
    for _ in range(n):
        ss = "".join(sorted(eval(input())))
        d[ss] = d.get(ss, 0) + 1
    for k, v in list(d.items()):
        if v != 1:
            ans += (v * (v - 1)) // 2
    print(ans)


if __name__ == "__main__":
    main()

-import math - - -def combinations_count(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -            ans += combinations_count(v, 2) +            ans += (v * (v - 1)) // 2