import sys

import os





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = int(sys.stdin.readline().rstrip())

    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]



    ret = 0

    sortedlines = {}

    for n in range(N):

        item = lines[n]

        if item in sortedlines:

            sortedlines[item] += 1

            ret += sortedlines[item] - 1

        else:

            sortedlines[item] = 1



    print(ret)





if __name__ == '__main__':

    main()

import sys

import os





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = int(sys.stdin.readline().rstrip())

    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]



    ret = 0

    sortedlines = {}

    for n in range(N):

        item = lines[n]

        if item in sortedlines:

            sortedlines[item] += 1

            ret += sortedlines[item]

        else:

            sortedlines[item] = 0



    print(ret)





if __name__ == '__main__':

    main()

import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]
    ret = 0
    sortedlines = {}
    for n in range(N):
        item = lines[n]
        if item in sortedlines:
            sortedlines[item] += 1
            ret += sortedlines[item] - 1
        else:
            sortedlines[item] = 1
    print(ret)


if __name__ == "__main__":
    main()

import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]
    ret = 0
    sortedlines = {}
    for n in range(N):
        item = lines[n]
        if item in sortedlines:
            sortedlines[item] += 1
            ret += sortedlines[item]
        else:
            sortedlines[item] = 0
    print(ret)


if __name__ == "__main__":
    main()

-            ret += sortedlines[item] - 1 +            ret += sortedlines[item] -            sortedlines[item] = 1 +            sortedlines[item] = 0