def main():

  import sys

  import math

  import collections

  n=int(eval(input()))

  word=["".join(sorted(str(eval(input())))) for _ in range(n) ]

  dic=collections.Counter(word)

  ans=0

  for k in list(dic.values()):

    if k>1:

      ans+=math.factorial(k)//math.factorial(k-2)//2

  print(ans)

  

if __name__=="__main__":

  main()

  
def main():

  import sys

  import math

  import collections

  n=int(eval(input()))

  word=["".join(sorted(str(sys.stdin.readline().rstrip()))) for _ in range(n) ]

  dic=collections.Counter(word)

  ans=0

  for k in list(dic.values()):

    if k>1:

      ans+=math.factorial(k)//math.factorial(k-2)//2

  print(ans)

  

if __name__=="__main__":

  main()

  
def main():
    import sys
    import math
    import collections

    n = int(eval(input()))
    word = ["".join(sorted(str(eval(input())))) for _ in range(n)]
    dic = collections.Counter(word)
    ans = 0
    for k in list(dic.values()):
        if k > 1:
            ans += math.factorial(k) // math.factorial(k - 2) // 2
    print(ans)


if __name__ == "__main__":
    main()

def main():
    import sys
    import math
    import collections

    n = int(eval(input()))
    word = ["".join(sorted(str(sys.stdin.readline().rstrip()))) for _ in range(n)]
    dic = collections.Counter(word)
    ans = 0
    for k in list(dic.values()):
        if k > 1:
            ans += math.factorial(k) // math.factorial(k - 2) // 2
    print(ans)


if __name__ == "__main__":
    main()

-    word = ["".join(sorted(str(eval(input())))) for _ in range(n)] +    word = ["".join(sorted(str(sys.stdin.readline().rstrip()))) for _ in range(n)]