N =int(eval(input()))

#横文字数、縦N行の行列を作成

s = [list(eval(input())) for i in range(N)]



#文字列をアルファベット順に並び替える

for i in range(len(s)):

    s[i].sort()

s.sort()   

ans = 0 

cnt = 1

for i in range(1,N):

    for j in range(10):

        #1文とその次の文の文字を比較

        #異なっていた場合はbreak

        if(s[i][j] != s[i-1][j]):

            break

    else:

        cnt +=1

        continue

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

    cnt =1

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

print(ans)
import sys

import collections

from functools import reduce

import operator as op





def nCr(n,r):

    r = min(r,n-r)

    """ operator.mul = 掛け算を行う関数"""

    """引数の２つ目は先頭を示す"""

    up = reduce(op.mul,list(range(n,n-r,-1)),1)

    down= reduce(op.mul,list(range(r,0,-1)),1)

    return up // down



def main():

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

    

    sorted_letters =[''.join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)]



    count = 0

    for c in list(collections.Counter(sorted_letters).values()):

        if c >=2:

            count +=nCr(c,2)

        

    

    print(count)

    

if __name__ == "__main__":

    main()
N = int(eval(input()))
# 横文字数、縦N行の行列を作成
s = [list(eval(input())) for i in range(N)]
# 文字列をアルファベット順に並び替える
for i in range(len(s)):
    s[i].sort()
s.sort()
ans = 0
cnt = 1
for i in range(1, N):
    for j in range(10):
        # 1文とその次の文の文字を比較
        # 異なっていた場合はbreak
        if s[i][j] != s[i - 1][j]:
            break
    else:
        cnt += 1
        continue
    ans += cnt * (cnt - 1) // 2
    cnt = 1
ans += cnt * (cnt - 1) // 2
print(ans)

import sys
import collections
from functools import reduce
import operator as op


def nCr(n, r):
    r = min(r, n - r)
    """ operator.mul = 掛け算を行う関数"""
    """引数の２つ目は先頭を示す"""
    up = reduce(op.mul, list(range(n, n - r, -1)), 1)
    down = reduce(op.mul, list(range(r, 0, -1)), 1)
    return up // down


def main():
    n = int(sys.stdin.readline().rstrip())
    sorted_letters = ["".join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)]
    count = 0
    for c in list(collections.Counter(sorted_letters).values()):
        if c >= 2:
            count += nCr(c, 2)
    print(count)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -# 横文字数、縦N行の行列を作成 -s = [list(eval(input())) for i in range(N)] -# 文字列をアルファベット順に並び替える -for i in range(len(s)): -    s[i].sort() -s.sort() -ans = 0 -cnt = 1 -for i in range(1, N): -    for j in range(10): -        # 1文とその次の文の文字を比較 -        # 異なっていた場合はbreak -        if s[i][j] != s[i - 1][j]: -            break -    else: -        cnt += 1 -        continue -    ans += cnt * (cnt - 1) // 2 -    cnt = 1 -ans += cnt * (cnt - 1) // 2 -print(ans) +import sys +import collections +from functools import reduce +import operator as op + + +def nCr(n, r): +    r = min(r, n - r) +    """ operator.mul = 掛け算を行う関数""" +    """引数の２つ目は先頭を示す""" +    up = reduce(op.mul, list(range(n, n - r, -1)), 1) +    down = reduce(op.mul, list(range(r, 0, -1)), 1) +    return up // down + + +def main(): +    n = int(sys.stdin.readline().rstrip()) +    sorted_letters = ["".join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)] +    count = 0 +    for c in list(collections.Counter(sorted_letters).values()): +        if c >= 2: +            count += nCr(c, 2) +    print(count) + + +if __name__ == "__main__": +    main()