qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
a, b = map(int, input().split())
kuchi = 1
cnt = 0
if kuchi >= b:
    break
else:
    for i in range(1, 20):
        if kuchi >= b:
                break
        else:
            for j in range(1, a ** i):
                if kuchi >= b:
                    break
                else:
                    if j < a ** i:
                        cnt += 1
                        kuchi = kuchi - 1 + a
                    else:
                        kuchi = kuchi * a
                        cnt += kuchi / a 
print(cnt)

# Fixed code:
a, b = map(int, input().split())
kuchi =  1
cnt = 0
if kuchi <= b:
    for i in range(1, 20):
        if kuchi >= b:
                break
        else:
            for j in range(1, a ** i):
                if kuchi >= b:
                    break
                else:
                    if j < a ** i:
                        cnt += 1
                        kuchi = kuchi - 1 + a
                    else:
                        kuchi = kuchi * a
                        cnt += kuchi / a 
print(cnt)
# Buggy code:
a,b = map(int,input().split())
print(int(-(-a//b)))

# Fixed code:
a,b = map(int,input().split())
print(int(-(-(b-1)//(a-1))))
# Buggy code:
a,b=map(int,input().split())
if (b-2)%(a-1)==0:
    print((b-2)//(a-1)+1)
else:
    print((b-2)//(a-1))

# Fixed code:
a, b = map(int, input().split())
print(0 if b == 1 else ((b - 1) + (a - 2)) // (a - 1))
# Buggy code:
A, B = map(int, input().split())

amari = (B-1)%(A-1)

if amari == 0:
    ans = (B-1)/(A-1)
else:
    ans = (B-1)//(A-1) + 1

print(ans)

# Fixed code:
A, B = map(int, input().split())

amari = (B-1)%(A-1)

if amari == 0:
    ans = (B-1)/(A-1)
else:
    ans = (B-1)//(A-1) + 1

ans2 = int(ans)

print(ans2)
# Buggy code:
A, B = map(int, input().split())
print((B+1)//(A-1))

# Fixed code:
A, B =  map(int, input().split())
print((-(-(B-A)//(A-1)))+1)
# Buggy code:
A = input().split()
count = 1
a = int(A[0])
b = int(A[1])
c = a
while a < b:
    a += c - 1
    count += 1
    print(a)
    if a >= b:
        break

print(count)


# Fixed code:
A = input().split()
count = 1
a = int(A[0])
b = int(A[1])
c = a

if b == 1:
    print(0)
else:
    while a < b:
        a += c - 1
        count += 1
        if a > b:
            break
    print(count)
# Buggy code:
A,B = map(int,input().split())
tap = 1
ans = 0
while(tap < B):
  ans += 1
  if(tap == 1):
    tap = tap + A
  else:
    tap = tap + A - 1
print(str(ans))

# Fixed code:
A,B = map(int,input().split())
tap = 1
ans = 0
while(tap < B):
  ans += 1
  tap = tap + A - 1
print(str(ans))
# Buggy code:
A, B = map(int, input().split())

ans = 0
taps = 1
while taps < B:
    print(taps)
    taps += A - 1
    ans += 1

print(ans)

# Fixed code:
A, B = map(int, input().split())

ans = 0
taps = 1
while taps < B:
    taps += A - 1
    ans += 1

print(ans)
# Buggy code:
A,B=map(int, input().split())
count=0

while B<(A-1)*count+1:
  count+=1
  
print(count)

# Fixed code:
A, B = map(int, input().split())
K = 0

while (A-1)*K+1 < B:
    K = K+1
print(K)
# Buggy code:
A, B = map(int,input().split())

t = A
c = 0
while True:
    if t<=B:
        t += (A-1)
        c+=1
    else:
        break

# Fixed code:
A, B = map(int,input().split())

t = 1
c = 0
while True:
    if t<B:
        t = (t-1)+A
        c += 1
    else:
        break

print(c)
# Buggy code:
a,b = map(int,input().split())

if a >= b:
  print(1)
else:
  c = 1
  count=0
  while b > c:
    c + = a-1
    
    count += 1
  print(count)


# Fixed code:
a,b = map(int,input().split())

c = 1
count=0
while b > c:
  c += a-1
    
  count += 1
print(count)
# Buggy code:
a, b = map(int, input().split())

if b == 1:
  print(0)
  exit()

if a >= b:
  print(1)
else:
  b -= a
  print(1 + b//a)

# Fixed code:
a, b = map(int, input().split())

if b == 1:
    print(0)
    exit()

if a >= b:
    print(1)
    exit()
b -=a
print(1 + -(-b//(a-1)))
# Buggy code:
s = input().split()
a = int(s[0])
b = int(s[1])
#print(a,b)
out = 1
n = 1
while b > out:
  out += a-1
  n +=1
print(n) 

# Fixed code:
s = input().split()
a = int(s[0])
b = int(s[1])
#print(a,b)
out = 1
n = 0
while b > out:
  out += a-1
  n +=1
print(n)
# Buggy code:
a,b=map(int,input().split())
c=(b-1)//(a-1)
if c-int(c)=0:
  print(str(c))
  
else:
  print(c+1)
  


# Fixed code:
a,b=map(int,input().split())
c=(b-1)/(a-1)
if c-int(c)==0:
  print(int(c))

else:
  print(int(c)+1)
# Buggy code:
a, b = map(int, input().split())

now = 1
ans = 0
if now >= b:
  print(ans)
ans += 1
now += a
if now >= b:
  print(ans)
while now < b:
  ans += 1
  now += a-1
print(ans)

# Fixed code:
a, b = map(int, input().split())

now = 1
ans = 0
while now < b:
  ans += 1
  now += a-1
print(ans)
# Buggy code:
a,b=map(int, input().split())

if a==b:
    print(1)
else:
    print((b-1)//(a-1)+1)


# Fixed code:
a,b = map(int,input().split())
if (b-1)%(a-1)==0:
    print((b-1)//(a-1))
else:
    print((b-1)//(a-1)+1)
# Buggy code:
a,b = map(int, input().split())
count = 0
if b == 1:
  print(0)
else:
  while True:
    if b <= (a-1)*count + a:
      break
    count += 1
  print(count)


# Fixed code:
a,b = map(int, input().split())
count = 1
if b == 1:
  print(0)
else:
  while True:
    if b <= (a-1)*(count-1) + a:
      break
    count += 1
  print(count)
# Buggy code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

A, B = map(int, input().split())

if B == 1:
    print(0)
    exit()

if A >= B:
    print(1)
    exit()

count = 2
B -= (A-1)
while True:
    if A >= B:
        print(count)
        exit()

    count += 1
    B -= (A-2)

# Fixed code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

A, B = map(int, input().split())

if B == 1:
    print(0)
    exit()

if A >= B:
    print(1)
    exit()

count = 2
B -= (A-1)
while True:
    if A >= B:
        print(count)
        exit()

    count += 1
    B -= (A-1)
# Buggy code:

a, b = map(int, input().split())
cnt = 0

while(a <= b):
    cnt += 1
    a += a

print(cnt)

# Fixed code:
a, b = map(int, input().split())
ports = 1
cnt = 0
while ports < b:
  ports += (a-1)
  cnt += 1
print(cnt)
# Buggy code:
a, b = map(int,input().split())
i=1
d=0
while d < b:
	
	d = i*(a-1) + a
	i+=1
print(i)

# Fixed code:
a, b = map(int,input().split())
i=0
d= 1
while d < b:
	d -= 1
	d += a
	i+=1
print(i)
# Buggy code:
a, b = map(int,input().split())
print((b + a - 2)//(a - 1))


# Fixed code:
a,b=map(int,input().split())
print(-( (-b+1)//(a-1) ))
# Buggy code:
a, b = map(int, input().split())
if b % a == 0:
    ans = b // a
else:
    ans = (b // a) + 1
    print(ans)

# Fixed code:
a,b=map(int,input().split())
if (b-1)%(a-1)==0:
  print((b-1)//(a-1))
else:
  print((b-1)//(a-1)+1)
# Buggy code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
d = {}
for i in range(n):
  sortsi = ''.join(sorted(s[i]))
  #print(sortsi)
  if sortsi in d: cnt+=1
  else: d[sortsi]=1
print(cnt)

# Fixed code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
d = {}
for i in range(n):
  sortsi = ''.join(sorted(s[i]))
  if sortsi in d:
    cnt+=d[sortsi]
    d[sortsi]+=1
  else: 
    d[sortsi]=1
print(cnt)
# Buggy code:
d = {}
for i in range(n):
    temp = [0 for i in range(26)]
    s = input()
    for c in s:
        t = ord(c)-97
        temp[t]+=1
    for i in range(26):
        temp[i] = str(temp[i])
    txt = ",".join(temp)
    if txt not in d:
        d[txt] = 1
    else:
        d[txt] += 1
ans = 0
for k in d:
    if d[k] != 1:
        ans += d[k]*(d[k]-1)/2
print(int(ans))


# Fixed code:
d = {}
n = int(input())
for i in range(n):
    temp = [0 for i in range(26)]
    s = input()
    for c in s:
        t = ord(c)-97
        temp[t]+=1
    for i in range(26):
        temp[i] = str(temp[i])
    txt = ",".join(temp)
    if txt not in d:
        d[txt] = 1
    else:
        d[txt] += 1
ans = 0
for k in d:
    if d[k] != 1:
        ans += d[k]*(d[k]-1)/2
print(int(ans))
# Buggy code:
n = int(input())
check = {}
lst = []

for _ in range(n):
  s = list(input())
  s.sort()
  s = "".join(s)
  lst.append(s)
  try:
    check[s]+=1
  else:
    check.update({s:1})
  
cnt=0
check_set = set(lst)
for c in check_set:
  temp_cnt = check[c]
  cnt +=  temp_cnt*(temp_cnt-1)/2
print(int(cnt))

# Fixed code:
n = int(input())
check = {}
lst = []

for _ in range(n):
  s = list(input())
  s.sort()
  s = "".join(s)
  lst.append(s)
  try:
    check[s]+=1
  except:
    check.update({s:1})
  
cnt=0
check_set = set(lst)
for c in check_set:
  temp_cnt = check[c]
  cnt +=  temp_cnt*(temp_cnt-1)/2
print(int(cnt))
# Buggy code:
import itertools
import collections
 
n = int(input())
lists = [str(input()) for i in range(n)]
 
lists2 = ["".join(sorted(i)) for i in lists]
l = collections.Counter(lists2)
c = l.values()
 
print(sum([i * (i - 1)/ 2 for i in c]))

# Fixed code:
import collections

n = int(input())
lists = [str(input()) for i in range(n)]

lists2 = ["".join(sorted(i)) for i in lists]
l = collections.Counter(lists2)
c = l.values()
 
print(int(sum([i * (i - 1)/ 2 for i in c])))
# Buggy code:
N = int(input())
S = [input() for i in range(N)]

d = {}

S_trans = [''.join(sorted(list(s))) for s in S]

count = 0
for s in S_trans:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
  count += d[s]

print(count)

# Fixed code:
N = int(input())
S = [input() for i in range(N)]
d = {}
S_trans = [''.join(sorted(list(s))) for s in S]
count = 0
for s in S_trans:
  if s in d:
    count += d[s]
    d[s] += 1
  else:
    d[s] = 1
print(count)
# Buggy code:
# Green Bin
n = int(input())
s = [input() for i in range(n)]
m = 0
list = {}
for i in s:
  i = ' '.join(sorted(i))
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
for i in list.values():
  l = i -1
  m = m + int(((l * (l + 1)) / 2))
print(list)

# Fixed code:
# Green Bin
n = int(input())
s = [input() for i in range(n)]
m = 0
list = {}
for i in s:
  i = ' '.join(sorted(i))
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
for i in list.values():
  l = i -1
  m = m + int(((l * (l + 1)) / 2))
print(m)
# Buggy code:
N = int(input())

strings = {}

for _ in range(N):
    s = sorted(list(input()))
    join_s = ''.join(s)
    if join_s in strings:
        strings[join_s] += 1
    else:
        strings[join_s] = 0
        
print(strings)

# Fixed code:
N = int(input())

strings = {}

ans = 0

for _ in range(N):
    s = sorted(list(input()))
    join_s = ''.join(s)
    if join_s in strings:
        strings[join_s] += 1
        ans += strings[join_s]
    else:
        strings[join_s] = 0

print(ans)
# Buggy code:
N = int(input())
s = sorted([sorted((input())) for i in range(N)])
count = 0

for i in range(N-1):
    num=0
    if(s[i]==s[i+1]):     
        num += 1
    elif(num>0):
        count += num*(num-1)/2
        
print(count)

# Fixed code:
N = int(input())
s = sorted(["".join(sorted((input()))) for i in range(N)])
count = 0

num=1
for i in range(N-1):
    if(s[i]==s[i+1]):
        num += 1
    elif(num>1):
        count += num*(num-1)/2
        num = 1
    
if(num>1):
    count += num*(num-1)/2
print(int(count))
# Buggy code:
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1
#print(dic.items())
 
ans = 0
for k,v in dic.items(): 
  #print(v)
  ans += (v-1)
  #ans += v*(v-1)//2
print(ans)

# Fixed code:
from collections import *
 
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic["".join(sorted(input()))] += 1
 
ans = 0
for k,v in dic.items(): 
  ans += int(v*(v-1)/2)
  #ans += v*(v-1)//2
print(ans)
# Buggy code:
import sys

n = int(input())

dd = {'a1':0}
cnt = 0

for i in range(n):
  s = ''.join(sorted(input()))
  if s in dd.keys():
    dd[s] += 1
    cnt += 1
  else:
    dd[s] = 0
  
  
print(cnt)  

# Fixed code:
import sys

n = int(input())

d = {}
cnt = 0

for i in range(n):
  s = ''.join(sorted(input()))
  if s in d.keys():
    d[s] += 1
    cnt += d[s]
  else:
    d[s] = 0
  
  
print(cnt)
# Buggy code:
from collections import Counter

N = int(input())
S = ["".join(sorted(input()[:-1])) for _ in range(N)]
c = Counter(S)
print(c)
print(sum([k*(k-1)//2 for k in c.values()]))

# Fixed code:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append("".join(sorted(input())))

c = Counter(S)
print(sum([k*(k-1)//2 for k in c.values()]))
# Buggy code:
n = int(input())
S = ["".join(sorted(input())) for _ in range(n)]
d = []
for i in S:
  d.setdefault(i, 0)
  d[i] += 1
ans = 0
for value in d.values:
  ans = value * (value) / 2
print(ans)

# Fixed code:
n = int(input())
S = [''.join(sorted(input())) for _ in range(n)]
d = {}
for i in S:
    d.setdefault(i, 0)
    d[i] += 1
ans = 0
for value in d.values():
    ans += value * (value - 1) // 2
print(ans)
# Buggy code:
from math import factorial
n = int(input())
d = {}
for i in range(n):
    s = input()
    ns = ''.join(sorted(s))
    if ns not in d.keys():
        d[ns] = 1
    else:
        d[ns] += 1
ans = 0
for i, v in d.items():
    if v != 1:
        ans += factorial(v) /(factorial(v-2)*2)
print(str(ans)[:-2])

# Fixed code:
from math import factorial, ceil
n = int(input())
d = {}
for i in range(n):
    s = input()
    ns = ''.join(sorted(s))
    if ns not in d.keys():
        d[ns] = 1
    else:
        d[ns] += 1
ans = 0
for i, v in d.items():
    if v != 1:
        ans += factorial(v) /(factorial(v-2)*2)
print(int(ans))
# Buggy code:
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

def choose(x):
  return factorial(x)/(2*factorial(x-2))

words = {}

for i in range(int(input())):
    s = "".join(sorted(si()))
    if s not in words:
        words[s] = 1
    else:
        words[s] += 1
ans = 0
print(words)
for i in words:
    ans += choose(words[i])
print(int(ans))

# Fixed code:
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

def choose(x):
  return factorial(x)/(2*factorial(x-2))

words = {}

for i in range(int(input())):
    s = "".join(sorted(si()))
    if s not in words:
        words[s] = 1
    else:
        words[s] += 1
ans = 0
for i in words:
    if words[i] == 1: continue
    ans += choose(words[i])
print(int(ans))
# Buggy code:
N = int(input())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

m = {}

def sort_str(s):
    return "".join(sorted(list(s)))

for i in range(N):
    s = str(input())
    ss = sort_str(s)

    if ss in m:
        m[ss] += 1
    else:
        m[ss] = 1


count = 0

for c in m.values():
    count += cmb(c, 2)

print(count)

# Fixed code:
N = int(input())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

m = {}

def sort_str(s):
    return "".join(sorted(list(s)))

for i in range(N):
    s = str(input())
    ss = sort_str(s)

    if ss in m:
        m[ss] += 1
    else:
        m[ss] = 1


count = 0

for c in m.values():
    if c > 1:
        count += cmb(c, 2)

print(count)
# Buggy code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
ans = 0
check_box = []
for s in S:
  s = sorted(s)
  s = ''.join(s)
  check_box.append(s)
C = Counter(check_box)
for i in C:
  ans += C[i]
print(ans-1)

# Fixed code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
ans = 0
check_box = []
for s in S:
  s = sorted(s)
  s = ''.join(s)
  check_box.append(s)
C = Counter(check_box)
for i in C:
  ans += C[i]*(C[i]-1)//2
print(ans)
# Buggy code:
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
for i in range(N):
    S[i] = ''.join(sorted(S[i]))

count = 0
t = dict()
for i in range(N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
ans = 0
for key in t:
    ans += (t[key]*(t[key]-1))/2


print(ans)

# Fixed code:
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
for i in range(N):
    S[i] = ''.join(sorted(S[i]))

count = 0
t = dict()
for i in range(N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
ans = 0
for key in t:
    ans += (t[key]*(t[key]-1)) // 2


print(ans)
# Buggy code:
import collections
import math
n=int(input())
s=[''.join(list(input()).sort()) for _ in range(n)]
l=collections.Counter(s).values()
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    if l[i]!=1:c+=combinations_count(l[i],2)
print(c)

# Fixed code:
import collections
import math
n=int(input())
s=[]
for i in range(n):
    sl=list(input())
    sl.sort()
    s.append("".join(sl))

l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)
# Buggy code:
n = int(input())
map = {}
for i in range(n):
  str = ''.join(sorted(input()))
  print(str)
  if str in map:
    map[str] += 1
  else:
    map[str] = 1

ans = 0
for value in map.values():
  ans += value * (value - 1) // 2

print(ans)

# Fixed code:
n = int(input())
map = {}
for i in range(n):
  str = ''.join(sorted(input()))
  if str in map:
    map[str] += 1
  else:
    map[str] = 1

ans = 0
for value in map.values():
  ans += value * (value - 1) // 2

print(ans)
# Buggy code:
from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    ans += factorial(v) / factorial(2) / factorial(v-2)
print(int(ans))


# Fixed code:
from math import factorial
N = int(input())
P = {}
ans = 0
def counter(s):
    ret = [0]*26
    for ss in s:
        ret[ord(ss)-ord('a')] += 1
    return tuple(ret)
for _ in range(N):
    s = input()
    c = counter(s)
    if not c in P.keys():
        P[c] = 1
    else:
        P[c] += 1
for v in P.values():
    if v > 1:
        ans += factorial(v) // factorial(2) // factorial(v-2)
print(ans)
# Buggy code:
import math

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
arr = {}
ans = 0
for _ in range(N):
    S = input()
    tmp_arr = []
    for i in range(10):
        tmp_arr.append(S[i])
    tmp_arr.sort()
    moji_sorted = ''
    for i in tmp_arr:
        moji_sorted += i
    if moji_sorted in arr:
        arr[moji_sorted] += 1
    else:
        arr[moji_sorted] = 1
# print(arr)

for i in arr.values():
    ans += C(i,2)

print(ans)





# Fixed code:
import math

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
arr = {}
ans = 0
for _ in range(N):
    S = input()
    tmp_arr = []
    for i in range(10):
        tmp_arr.append(S[i])
    tmp_arr.sort()
    moji_sorted = ''
    for i in tmp_arr:
        moji_sorted += i
    if moji_sorted in arr:
        arr[moji_sorted] += 1
    else:
        arr[moji_sorted] = 1
# print(arr)

for i in arr.values():
    if i-2 >= 0:
        ans += C(i,2)

print(ans)
# Buggy code:
from collections import Counter
from itertools import combinations
n = int(input())
lst = [str(Counter(input()).values()) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

# Fixed code:
from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)
# Buggy code:
Ncount = int(input())
strings = []
count_flag = 0
letters = {}
letters_count = []
for i in range(Ncount):
  strings.append(''.join(sorted(input())))
print(strings)
for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    letters[i] += letters[i] - 1

for i in letters:
  count_flag += letters[i] 

print(count_flag)

# Fixed code:
Ncount = input()
strings = []
count_flag = 0
letters = {}
for i in range(int(Ncount)):
  strings.append(''.join(sorted(input())))

for i in strings:
  if i not in letters:
    letters[i] = 0
  else :
    letters[i] += 1
    count_flag += letters[i]

print(count_flag)
# Buggy code:
n = int(input())
lis = []
for _ in range(n):
  s = list(str(input()))
  s.sort()
  lis.append(s)
lis.sort()
ans = 0
num = 0
for i in range(n-1):
  if lis[i+1] == lis[i]:
    num += 1
  else:
    ans += (num * (num+1))//2
    num = 0
print(ans)

# Fixed code:
n = int(input())
lis = []
for _ in range(n):
  s = list(str(input()))
  s.sort()
  lis.append(s)
lis.sort()
ans = 0
num = 0
for i in range(n-1):
  if lis[i+1] == lis[i]:
    num += 1
  else:
    ans += (num * (num+1))//2
    num = 0
ans += (num * (num+1))//2
print(ans)
# Buggy code:
alphabet = "abcdefghijklmnopqrstuvwxyz"


n = int(input())
res = dict()
ans = 0
for _ in range(n):
    s = str(input())
    s.sort()
    if s not in res.keys():
      res[s] = 1
    else:
      ans += res[s]
      res[s] += 1
print(ans)
      

# Fixed code:
alphabet = "abcdefghijklmnopqrstuvwxyz"


n = int(input())
res = dict()
ans = 0
for _ in range(n):
    s = str(input())
    s = "".join(sorted(s))
    if s not in res.keys():
      res[s] = 1
    else:
      ans += res[s]
      res[s] += 1
print(ans)