import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd



def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N =  INT()

s = ["".join(sorted(eval(input()))) for _ in range(N)]



s.sort()



ans = 0

count = 0

tmp = ""

for i in s:

	if tmp == i:

		count += 1

	else:

		ans += count*(count+1)//2

		count = 0

		tmp = i

ans += count*(count+1)//2

print(ans)

import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product

from operator import itemgetter, mul

from copy import deepcopy

from string import ascii_lowercase, ascii_uppercase, digits

from fractions import gcd

from bisect import bisect



def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

def MAP(): return list(map(int, input().split()))

def LIST(): return list(map(int, input().split()))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7



N = INT()

s = ["".join(sorted(eval(input()))) for _ in range(N)]

dic = defaultdict(int)

for x in s:

	dic[x] += 1

ans = 0

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

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

print(ans)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
s = ["".join(sorted(eval(input()))) for _ in range(N)]
s.sort()
ans = 0
count = 0
tmp = ""
for i in s:
    if tmp == i:
        count += 1
    else:
        ans += count * (count + 1) // 2
        count = 0
        tmp = i
ans += count * (count + 1) // 2
print(ans)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


def MAP():
    return list(map(int, input().split()))


def LIST():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
s = ["".join(sorted(eval(input()))) for _ in range(N)]
dic = defaultdict(int)
for x in s:
    dic[x] += 1
ans = 0
for n in list(dic.values()):
    ans += n * (n - 1) // 2
print(ans)

-from itertools import permutations, combinations, product, accumulate +from itertools import permutations, combinations, product +from bisect import bisect -s.sort() +dic = defaultdict(int) +for x in s: +    dic[x] += 1 -count = 0 -tmp = "" -for i in s: -    if tmp == i: -        count += 1 -    else: -        ans += count * (count + 1) // 2 -        count = 0 -        tmp = i -ans += count * (count + 1) // 2 +for n in list(dic.values()): +    ans += n * (n - 1) // 2