# 2019-11-16 14:51:41(JST)

import sys

import collections

# import math

# from string import ascii_lowercase, ascii_uppercase, digits

# from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l

# import itertools

# from functools import reduce

# import operator as op

from scipy.misc import comb # comb(n, r, exact=True)

# import numpy as np

# import heapq

# import array





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 += comb(c, 2, exact=True)



    print(count)





if __name__ == "__main__":

    main()

import sys

from collections import Counter



n, *s = sys.stdin.read().split()

n = int(n)



def comb_2(n):

    return n * (n - 1) // 2



def main():

    t = [''.join(sorted(t)) for t in s]



    c = Counter(t)

    pairs_cnt = 0

    for v in list(c.values()):

        pairs_cnt += comb_2(v)

    

    return pairs_cnt

    

if __name__ == '__main__':

    ans = main()

    print(ans)
# 2019-11-16 14:51:41(JST)
import sys
import collections

# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
# from functools import reduce
# import operator as op
from scipy.misc import comb  # comb(n, r, exact=True)

# import numpy as np
# import heapq
# import array
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 += comb(c, 2, exact=True)
    print(count)


if __name__ == "__main__":
    main()

import sys
from collections import Counter

n, *s = sys.stdin.read().split()
n = int(n)


def comb_2(n):
    return n * (n - 1) // 2


def main():
    t = ["".join(sorted(t)) for t in s]
    c = Counter(t)
    pairs_cnt = 0
    for v in list(c.values()):
        pairs_cnt += comb_2(v)
    return pairs_cnt


if __name__ == "__main__":
    ans = main()
    print(ans)

-# 2019-11-16 14:51:41(JST) -import collections +from collections import Counter -# import math -# from string import ascii_lowercase, ascii_uppercase, digits -# from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l -# import itertools -# from functools import reduce -# import operator as op -from scipy.misc import comb  # comb(n, r, exact=True) +n, *s = sys.stdin.read().split() +n = int(n) -# import numpy as np -# import heapq -# import array + +def comb_2(n): +    return n * (n - 1) // 2 + + -    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 += comb(c, 2, exact=True) -    print(count) +    t = ["".join(sorted(t)) for t in s] +    c = Counter(t) +    pairs_cnt = 0 +    for v in list(c.values()): +        pairs_cnt += comb_2(v) +    return pairs_cnt -    main() +    ans = main() +    print(ans)