After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.

Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick.

Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks.

Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of digits in the cards Sherlock and Moriarty are going to use.

The second line contains n digits — Sherlock's credit card number.

The third line contains n digits — Moriarty's credit card number.


-----Output-----

First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty.


-----Examples-----
Input
3
123
321

Output
0
2

Input
2
88
00

Output
2
0



-----Note-----

First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.

Difficulty: EASY
Tags: Dynamic programming

Sorting

Data structures

Greedy algorithms
Skill types: Dynamic programming

Sorting

Data structures

Greedy algorithms

Starter code:

Solutions:
from copy import copy
n = int(input())
sh = input()
mo = input()
shf = [0] * 10
mof = [0] * 10
for c in sh:
	shf[int(c)] += 1
for c in mo:
	mof[int(c)] += 1
oshf = copy(shf)
omof = copy(mof)
sav = 0
hit = 0
for i in range(9, -1, -1):
	m = min(shf[i], mof[i])
	shf[i] -= m
	mof[i] -= m
	m = min(sav, shf[i])
	sav -= m
	shf[i] -= m
	hit += shf[i]
	sav += mof[i]
	for j in range(10):
		m = min(mof[j], shf[i])
		mof[j] -= m
		shf[i] -= m
minhit = hit
shf = oshf
mof = omof
for i in range(10):
	m = min(mof[i], shf[9])
	mof[i] -= m
	shf[9] -= m
maxhit = 0
sav = mof[9]
for i in range(8, -1, -1):
	m = min(shf[i], sav)
	maxhit += m
	shf[i] -= m
	sav -= m
	sav += mof[i]
print(minhit)
print(maxhit)


from collections import Counter

def flicks(a, b, mx=False):
	a_counter = Counter(a)
	b_counter = Counter(b)
	res = 0
	for i in a:
		for j in range(i + mx, 10):
			if j in b_counter and b_counter[j] > 0:
				b_counter[j] -= 1
				res += 1
				break
	if not mx:
		return len(a) - res
	return res
_ = input()
a = [int(i) for i in input()]
b = [int(i) for i in input()]
a.sort()
b.sort()
print(flicks(a, b))
print(flicks(a, b, True))


n = int(input())
s = input()
m = input()
scount = [0] * 10
mcount = [0] * 10

def get(i):
	return int(i) - 0
for i in range(0, n):
	scount[get(s[i])] += 1
	mcount[get(m[i])] += 1
cmcount = [i for i in mcount]
for i in range(0, 9):
	if scount[i] > mcount[i]:
		mcount[i + 1] -= scount[i] - mcount[i]
print(scount[9] - mcount[9])
a = cmcount[0]
max = 0
for i in range(9, 0, -1):
	if cmcount[i] > scount[i - 1]:
		cmcount[i - 1] += cmcount[i] - scount[i - 1]
		max += scount[i - 1]
	else:
		max += cmcount[i]
print(max)


from sys import stdin
N = int(stdin.readline())
sherlock = list(map(int, stdin.readline().strip()))
moriarty = list(map(int, stdin.readline().strip()))
mcounts = [0] * 10
for m in moriarty:
	mcounts[m] += 1

def minflicks(counts):
	flicks = 0
	for s in sherlock:
		si = s
		while counts[si % 10] == 0:
			si += 1
		if si % 10 < s:
			flicks += 1
		counts[si % 10] -= 1
	return flicks

def maxflicks(counts):
	flicks = 0
	for s in sherlock:
		si = s + 1
		while counts[si % 10] == 0:
			si += 1
		if si % 10 > s:
			flicks += 1
		counts[si % 10] -= 1
	return flicks
print(minflicks(mcounts[:]))
print(maxflicks(mcounts[:]))


n = int(input())
s = input()
m = input()
if s == 0:
	num_s = [0] * n
else:
	num_s = [int(x) for x in str(s)]
if m == 0:
	num_m = [0] * n
else:
	num_m = [int(x) for x in str(m)]
num_m.sort()
num_s.sort()
a = 0
j = 0
for i in range(n):
	p = num_s[i]
	while j < n and num_m[j] < p:
		j += 1
	if j == n:
		break
	else:
		a += 1
		j += 1
print(n - a)
b = 0
j = 0
for i in range(n):
	p = num_s[i]
	while j < n and num_m[j] <= p:
		j += 1
	if j == n:
		break
	else:
		b += 1
		j += 1
print(b)


import sys
n = int(sys.stdin.readline())
sher = list(input())
mon = list(input())
sher.sort()
mon.sort()
c = mon.copy()
d = sher.copy()
i = 0
j = 0
ans1 = 0
ans2 = 0
while i < n and j < n:
	if c[i] >= d[j]:
		i += 1
		j += 1
	else:
		i += 1
		ans1 += 1
print(ans1)
c = mon.copy()
d = sher.copy()
i = 0
j = 0
while i < n and j < n:
	if c[i] > d[j]:
		ans2 += 1
		i += 1
		j += 1
	else:
		i += 1
print(ans2)


n = int(input())
a = list(input())
b = list(input())
a.sort()
b.sort()
j = 0
for i in b:
	if int(i) >= int(a[j]):
		j += 1
print(n - j)
j = 0
for i in b:
	if int(i) > int(a[j]):
		j += 1
print(j)


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
a.sort()
b.sort()
sher = 0
mor = 0
for i in range(0, n):
	if b[i] >= a[sher]:
		sher = sher + 1
	if b[i] > a[mor]:
		mor = mor + 1
print(n - sher)
print(mor)


def value_index_greater_or_equal_than(ordered_list, number):
	for i in range(0, len(ordered_list)):
		element = ordered_list[i]
		if element >= number:
			return i
	return -1

def flicks(sherlocks_card, sorted_moriarty_card, prefer_flicks):
	flicks = 0
	for digit in sherlocks_card:
		increment = 1 if prefer_flicks else 0
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + increment)
		if minimum_index >= 0:
			flicks = flicks + 1 if increment else flicks
			sorted_moriarty_card.pop(minimum_index)
		else:
			flicks = flicks if increment else flicks + 1
			sorted_moriarty_card.pop(0)
	return flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_card.sort()
	min_moriartys_flicks = flicks(sherlocks_card, moriartys_card.copy(), False)
	max_sherlocks_flicks = flicks(sherlocks_card, moriartys_card.copy(), True)
	return (min_moriartys_flicks, max_sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


a = int(input())
b = sorted(input())
c = sorted(input())
bc = [b.count('0')]
cc = [c.count('0')]
for i in range(1, 10):
	bc.append(b.count(str(i)) + bc[-1])
	cc.append(c.count(str(i)) + cc[-1])
count = cc[0]
canSolve = bc[0]
m = min(count, canSolve)
for i in range(1, 10):
	count = cc[i] - cc[i - 1]
	canSolve = bc[i]
	canSolve -= min(canSolve, m)
	m += min(count, canSolve)
print(a - m)
m = 0
for i in range(1, 10):
	count = cc[i] - cc[i - 1]
	canSolve = bc[i - 1]
	canSolve -= min(canSolve, m)
	m += min(count, canSolve)
print(m)


n = int(input())
a = sorted(map(int, input()))
b = sorted(map(int, input()))
r1 = n
j = 0
try:
	for i in range(n):
		while a[i] > b[j]:
			j += 1
			if j >= n:
				raise UserWarning
		r1 -= 1
		j += 1
		if j >= n:
			raise UserWarning
except UserWarning:
	pass
r2 = 0
j = 0
try:
	for i in range(n):
		while a[i] >= b[j]:
			j += 1
			if j >= n:
				raise UserWarning
		r2 += 1
		j += 1
		if j >= n:
			raise UserWarning
except UserWarning:
	pass
print(r1)
print(r2)


n = int(input())
a = sorted([int(x) for x in input()])
b = sorted([int(x) for x in input()])
(c, d) = (0, 0)
for i in range(n):
	if b[i] >= a[c]:
		c += 1
	if b[i] > a[d]:
		d += 1
print(n - c)
print(d)


import copy

def get_min(a, b):
	a.sort(reverse=True)
	b.sort(reverse=True)
	r = 0
	pos = 0
	for i in a:
		if b[pos] >= i:
			pos += 1
		else:
			r += 1
	return r

def get_max(a, b):
	rem = copy.copy(b)
	r = 0
	for i in a:
		m = None
		for j in rem:
			if j > i:
				if m is None or m > j:
					m = j
		if m is not None:
			rem.remove(m)
			r += 1
	return r
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
print(get_min(a, b))
print(get_max(a, b))


from copy import copy

def find_min(pp1, pp2):
	p1 = copy(pp1)
	p2 = copy(pp2)
	for i in range(9, -1, -1):
		for j in range(i, -1, -1):
			if p2[i] <= 0:
				break
			k = min(p1[j], p2[i])
			p1[j] -= k
			p2[i] -= k
	return sum(p1)

def find_max(p1, p2):
	count = 0
	for i in range(9, -1, -1):
		for j in range(i - 1, -1, -1):
			if p2[i] <= 0:
				break
			k = min(p1[j], p2[i])
			count += k
			p1[j] -= k
			p2[i] -= k
	return count
n = int(input())
s1 = input()
s2 = input()
p1 = [0 for _ in range(10)]
p2 = [0 for _ in range(10)]
for i in range(n):
	p1[int(s1[i])] += 1
	p2[int(s2[i])] += 1
print(find_min(p1, p2))
print(find_max(p1, p2))


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
a = list(map(int, list(inp())))
b = list(map(int, list(inp())))
a.sort()
b.sort()
m1 = m2 = 0
i = j = 0
while j < n:
	while j < n and a[i] >= b[j]:
		j += 1
	if j == n:
		break
	m1 += 1
	i += 1
	j += 1
i = j = 0
while j < n:
	while j < n and a[i] > b[j]:
		j += 1
	if j == n:
		break
	m2 += 1
	i += 1
	j += 1
print(n - m2)
print(m1)


n = int(input())
s1 = input()
s2 = input()
a1 = [0 for i in range(10)]
a2 = [0 for i in range(10)]
for i in s1:
	a1[ord(i) - ord('0')] += 1
for i in s2:
	a2[ord(i) - ord('0')] += 1
o1 = 0
o2 = 0
ii = 9
jj = 0
for i in range(9, -1, -1):
	for j in range(a1[i]):
		if ii >= 0 and a2[ii] == 0:
			while ii >= 0 and a2[ii] == 0:
				ii -= 1
		if jj < n and a2[jj] == 0:
			while jj < n and a2[jj] == 0:
				jj += 1
		if ii < i:
			o1 += 1
			a2[jj] -= 1
		elif ii == i:
			a2[ii] -= 1
		else:
			a2[ii] -= 1
a2 = [0 for i in range(10)]
for i in s2:
	a2[ord(i) - ord('0')] += 1
ii = 1
for i in range(9):
	ii = i + 1
	for j in range(a1[i]):
		if ii < 10 and a2[ii] == 0:
			while ii < 10 and a2[ii] == 0:
				ii += 1
		if ii < 10 and ii > i:
			o2 += 1
		if ii < 10:
			a2[ii] -= 1
print(o1)
print(o2)


n = int(input())
il = [int(c) for c in input()]
jl = [int(c) for c in input()]
il.sort()
jl.sort()
i = 0
j = 0
lc = 0
while j < n:
	if jl[j] >= il[i]:
		i += 1
	else:
		lc += 1
	j += 1
print(lc)
i = 0
j = 0
wc = 0
while j < n:
	if jl[j] > il[i]:
		i += 1
		wc += 1
	j += 1
print(wc)


n = int(input())
s = list(map(int, sorted(input())))
m = list(map(int, sorted(input())))
mini = 0
i = 0
j = 0
while i < n and j < n:
	if m[i] < s[j]:
		mini += 1
		i += 1
	else:
		i += 1
		j += 1
maxi = 0
i = 0
j = 0
while i < n and j < n:
	if m[i] <= s[j]:
		i += 1
	else:
		maxi += 1
		i += 1
		j += 1
print(mini)
print(maxi)


from sys import stdin, stdout
n = int(stdin.readline())
first = sorted(list(map(int, list(stdin.readline().strip()))))
second = sorted(list(map(int, list(stdin.readline().strip()))))
ans = [0, 0]
ind1 = 0
ind2 = 0
cnt = 0
while ind2 < n:
	while ind2 < n and second[ind2] < first[ind1]:
		ind2 += 1
		cnt += 1
	ind1 += 1
	ind2 += 1
ans[0] = cnt
ind1 = 0
ind2 = 0
cnt = 0
while ind2 < n:
	while ind2 < n and second[ind2] <= first[ind1]:
		ind2 += 1
	if ind2 < n:
		cnt += 1
	ind1 += 1
	ind2 += 1
ans[1] = cnt
stdout.write('\n'.join(list(map(str, ans))))


n = int(input())
sherlock = list(map(int, input()))
moriarty = list(map(int, input()))
moriarty.sort()
res = 0
x = 0
var = moriarty[:]
for i in sherlock:
	for j in moriarty:
		if j > i:
			moriarty.remove(j)
			res += 1
			break
for i in sherlock:
	y = True
	for j in var:
		if i == j or j > i:
			var.remove(j)
			y = False
			break
	if y:
		x += 1
print(x)
print(res)


n = int(input())
a = input()
a = [int(i) for i in a]
b = input()
b = [int(i) for i in b]
a.sort()
b.sort()
i = j = ma = mi = 0
while i < n and j < n:
	if b[j] > a[i]:
		ma += 1
		j += 1
		i += 1
	else:
		j += 1
i = j = 0
while i < n and j < n:
	if b[j] >= a[i]:
		mi += 1
		j += 1
		i += 1
	else:
		j += 1
print(n - mi)
print(ma)


n = int(input())
S = input()
S1 = input()
S = sorted(S)
S1 = sorted(S1)
k = n
k1 = 0
p = 0
for i in range(n):
	if S1[i] >= S[p]:
		k = k - 1
		p = p + 1
v = -1
v1 = -1
mi = 10000000000
for i in range(n):
	v = -1
	for j in range(n):
		if int(S[i]) < int(S1[j]) and abs(int(S[i]) - int(S1[j])) < mi and (S[i] != -1) and (S1[j] != -1):
			mi = abs(int(S[i]) - int(S1[j]))
			v = i
			v1 = j
	if v != -1:
		S[v] = -1
		S1[v1] = -1
		mi = 10000000000000000
		k1 = k1 + 1
print(k)
print(k1)


def gen(s):
	a = {}
	for i in s:
		i = int(i)
		if i in a:
			a[i] += 1
		else:
			a[i] = 1
	return a
n = int(input())
a = input()
b = input()
ans = [n, 0]
(M, M2) = (gen(b), gen(b))
for i in a:
	i = int(i)
	f = [0, 0]
	for j in range(i, 10):
		if j in M and M[j] > 0 and (f[0] == 0):
			M[j] -= 1
			ans[0] -= 1
			f[0] = 1
		if j + 1 in M2 and M2[j + 1] > 0 and (f[1] == 0):
			M2[j + 1] -= 1
			ans[1] += 1
			f[1] = 1
		if sum(f) == 2:
			break
print(ans[0], ans[1], sep='\n')


from collections import defaultdict
n = int(input())
s1 = input()
s2 = input()
occ = defaultdict(int)
for i in s2:
	occ[int(i)] += 1

def find_min(x):
	global occ
	for i in range(x, 10):
		if occ[i] > 0:
			occ[i] -= 1
			return i
	for i in range(0, x):
		if occ[i] > 0:
			occ[i] -= 1
			return i
mn = 0
for i in s1:
	y = find_min(int(i))
	if y < int(i):
		mn += 1
print(mn)
for i in s2:
	occ[int(i)] += 1

def find_closest(x):
	global occ
	for i in range(x + 1, 10):
		if occ[i] > 0:
			occ[i] -= 1
			return i
	for i in range(0, x + 1):
		if occ[i] > 0:
			occ[i] -= 1
			return i
mx = 0
for i in s1:
	y = find_closest(int(i))
	if y > int(i):
		mx += 1
print(mx)


import math
import sys
n = int(input())
a = list(str(input()))
b = list(str(input()))
min_res = 0
max_res = 0
ap = {}
bp = {}
for i in range(0, 10):
	ap[i] = a.count(str(i))
	bp[i] = b.count(str(i))
for i in range(9, 0, -1):
	k = min(ap[i - 1], bp[i])
	max_res += k
	bp[i - 1] = bp[i - 1] + bp[i] - k
ap = {}
bp = {}
for i in range(0, 10):
	ap[i] = a.count(str(i))
	bp[i] = b.count(str(i))
bp[-1] = 0
for i in range(9, -1, -1):
	k = min(ap[i], bp[i])
	min_res += ap[i] - k
	bp[i - 1] += bp[i] - k
print(min_res)
print(max_res)


import sys
input = sys.stdin.readline
n = int(input())
sher = input()
mor = input()
sher = [int(ch) for ch in sher[0:n]]
mor = [ch for ch in mor[0:n]]
sher.sort()
mor.sort()
(x, y) = (0, 0)
for i in range(0, n):
	if int(mor[i]) >= int(sher[x]):
		x += 1
	if int(mor[i]) > int(sher[y]):
		y += 1
print(n - x)
print(y)


n = int(input())
a = sorted(map(int, list(input())))
b = sorted(map(int, list(input())))
used1 = [0 for i in range(n)]
used2 = [0 for i in range(n)]
ans1 = 0
ans2 = 0
for i in range(n):
	j = 0
	while j < n and (used1[j] == 1 or b[j] <= a[i]):
		j += 1
	if j != n:
		used1[j] = 1
		ans1 += 1
	j = 0
	while j < n and (used2[j] == 1 or b[j] < a[i]):
		j += 1
	if j != n:
		used2[j] = 1
		ans2 += 1
print(n - ans2)
print(ans1)


input()
a = list(input())
b = list(input())
a.sort()
b.sort()
(i, j) = (0, 0)
count = 0
while True:
	if b[i] > a[j]:
		i += 1
		j += 1
		count += 1
	else:
		i += 1
	if i == len(b):
		break
x = 0
for i in range(len(a)):
	if b[i] >= a[x]:
		x += 1
print(len(a) - x)
print(count)


n = int(input())
(a, b) = (sorted(map(int, input())), sorted(map(int, input())))
b1 = b[:]
res1 = j = 0
for i in range(n):
	while j < n and b1[j] < a[i]:
		j += 1
	if j < n:
		(b1[i], b1[j]) = (b1[j], b1[i])
	res1 += a[i] > b1[i]
b1 = b[:]
res2 = j = 0
for i in range(n):
	while j < n and b1[j] <= a[i]:
		j += 1
	if j < n:
		(b1[i], b1[j]) = (b1[j], b1[i])
	res2 += b1[i] > a[i]
print(res1)
print(res2)


k = int(input())
(a, b) = ([int(f) for f in input()], [int(f) for f in input()])
b = list(sorted(b))
(f, u) = ([], [])
t = list(b)
g = 0
for x in a:
	for y in t:
		if y >= x:
			t.remove(y)
			break
i = list(b)
for x in a:
	o = True
	for y in i:
		if y > x:
			o = False
			i.remove(y)
			g += 1
			break
	if o and i:
		u += [i.pop(0)]
print(len(t))
print(g)


import bisect
n = int(input())
sherlock = sorted(input())
moriarti = sorted(input())
ma = 0
(i, j) = (0, 0)
while i < n and j < n:
	if sherlock[i] < moriarti[j]:
		ma += 1
		i += 1
	j += 1
mi = 0
(i, jl, jr) = (n - 1, 0, n - 1)
while i >= 0 and jl <= jr:
	if sherlock[i] > moriarti[jr]:
		mi += 1
		jl += 1
	else:
		jr -= 1
	i -= 1
print('%d\n%d' % (mi, ma))


n = int(input())
s = input()
s = [s[i] for i in range(n)]
m = input()
m = [m[i] for i in range(n)]
s.sort(reverse=True)
m.sort(reverse=True)
i = 0
j = 0
a = 0
while i < n and j < n:
	if s[i] > m[j]:
		i += 1
		a += 1
	else:
		i += 1
		j += 1
print(a)
i = 0
j = 0
b = 0
while i < n and j < n:
	if m[j] > s[i]:
		i += 1
		j += 1
		b += 1
	else:
		i += 1
print(b)


n = int(input())
sher = list(map(int, input()))
mori = list(map(int, input()))
sher.sort()
mori.sort()
(i, j) = (0, 0)
min_flicks_mori = 0
while i < n and j < n:
	if mori[j] >= sher[i]:
		i += 1
		j += 1
	else:
		j += 1
		min_flicks_mori += 1
print(min_flicks_mori)
(i, j) = (0, 0)
max_flicks_sher = n
while i < n and j < n:
	if mori[j] > sher[i]:
		i += 1
		j += 1
	else:
		j += 1
		max_flicks_sher -= 1
print(max_flicks_sher)


n = int(input())
sher = input()
mor = input()
sher = [int(d) for d in sher]
sher.sort()
md1 = [0 for d in range(10)]
md2 = [0 for d in range(10)]
for d in mor:
	md1[int(d)] += 1
	md2[int(d)] += 1
m = 0
M = 0
for d in sher:
	flag = 0
	for i in range(int(d), 10):
		if md1[i] > 0:
			md1[i] -= 1
			flag = 1
			break
	if flag == 0:
		m += 1
		for i in range(int(d)):
			if md1[i] > 0:
				md1[i] -= 1
				break
for d in sher:
	flag = 0
	for i in range(int(d) + 1, 10):
		if md2[i] > 0:
			md2[i] -= 1
			flag = 1
			M += 1
			break
	if flag == 0:
		for i in range(int(d) + 1):
			if md2[i] > 0:
				md2[i] -= 1
				break
print(m)
print(M)


def main():
	n = int(input())
	a = list(map(int, input()))
	b = list(map(int, input()))
	cnt = [0 for i in range(10)]
	for i in b:
		cnt[i] += 1
	min_gotten = 0
	for i in a:
		for j in range(i, 10):
			if cnt[j] > 0:
				cnt[j] -= 1
				break
		else:
			for j in range(i):
				if cnt[j] > 0:
					cnt[j] -= 1
					break
			min_gotten += 1
	print(min_gotten)
	for i in b:
		cnt[i] += 1
	max_given = 0
	for i in a:
		for j in range(i + 1, 10):
			if cnt[j] > 0:
				cnt[j] -= 1
				max_given += 1
				break
		else:
			for j in range(i + 1):
				if cnt[j] > 0:
					cnt[j] -= 1
					break
	print(max_given)
main()


n = int(input())
a = input()
b = input()
a = sorted(a)
b = sorted(b)
Min = 0
idxa = 0
idxb = 0
while idxa < n and idxb < n:
	if b[idxb] < a[idxa]:
		idxb += 1
		Min += 1
	else:
		idxa += 1
		idxb += 1
print(Min)
Max = 0
idxa = n - 1
idxb = n - 1
while idxa >= 0 and idxb >= 0:
	if a[idxa] < b[idxb]:
		Max += 1
		idxa -= 1
		idxb -= 1
	else:
		idxa -= 1
print(Max)


n = int(input())
shl = input()[0:n]
mrl = input()[0:n]
sh = {d: shl.count(str(d)) for d in range(10)}
mr = {d: mrl.count(str(d)) for d in range(10)}
mr2 = mr.copy()

def spend(m, mor, startwith=0):
	spent = 0
	for i in range(startwith, 10):
		dec = min(m - spent, mor[i])
		spent += dec
		mor[i] -= dec
		if m == spent:
			break
	return spent
min_pen = 0
for d in range(9, -1, -1):
	if sh[d] == 0:
		continue
	penalty = sh[d] - spend(sh[d], mr, d)
	if penalty > 0:
		spend(penalty, mr, 0)
		min_pen += penalty
print(min_pen)
max_win = 0
for d in range(9):
	if sh[d] == 0:
		continue
	won = spend(sh[d], mr2, d + 1)
	max_win += won
	if won < sh[d]:
		spend(sh[d] - won, mr2, 0)
print(max_win)


n = int(input())
s = sorted([int(c) for c in input()])
m = sorted([int(c) for c in input()])

def maximize(s, m):
	(i, ans) = (0, 0)
	for j in range(len(m)):
		if s[i] < m[j]:
			i += 1
			ans += 1
	return ans

def minimize(s, m):
	(j, ans) = (len(m) - 1, 0)
	for i in range(len(s) - 1, -1, -1):
		if s[i] <= m[j]:
			j -= 1
		else:
			ans += 1
	return ans
print(minimize(s, m))
print(maximize(s, m))


n = int(input())
a = input()
b = input()
a = list(a)
b = list(b)
a.sort()
b.sort()
i = n - 1
j = n - 1
c1 = 0
c2 = 0
while i >= 0 and j >= 0:
	if b[j] > a[i]:
		c1 += 1
		j = j - 1
		i = i - 1
	else:
		i = i - 1
i = j = n - 1
while i >= 0 and j >= 0:
	if b[j] >= a[i]:
		c2 += 1
		j = j - 1
		i = i - 1
	else:
		i = i - 1
print(n - c2)
print(c1)


class CodeforcesTask777BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.she = []
		self.mor = []

	def read_input(self):
		self.n = int(input())
		self.she = [int(x) for x in input()]
		self.mor = [int(x) for x in input()]

	def process_task(self):
		self.she.sort(reverse=True)
		self.mor.sort(reverse=True)
		mx = max(max(self.she), max(self.mor))
		atta = 0
		deff = 0
		shecnt = [0 for x in range(mx + 1)]
		morcnt = [0 for x in range(mx + 1)]
		for x in range(self.n):
			shecnt[self.she[x]] += 1
			morcnt[self.mor[x]] += 1
		for base in range(mx, -1, -1):
			for it in range(shecnt[base]):
				for i in range(mx, base, -1):
					if morcnt[i] and shecnt[base] > 0:
						atta += 1
						morcnt[i] -= 1
						shecnt[base] -= 1
		shecnt = [0 for x in range(mx + 1)]
		morcnt = [0 for x in range(mx + 1)]
		for x in range(self.n):
			shecnt[self.she[x]] += 1
			morcnt[self.mor[x]] += 1
		for base in range(mx, -1, -1):
			for it in range(shecnt[base]):
				for i in range(mx, base - 1, -1):
					if morcnt[i] and shecnt[base] > 0:
						deff += 1
						morcnt[i] -= 1
						shecnt[base] -= 1
		self.result = '{0}\n{1}'.format(self.n - deff, atta)

	def get_result(self):
		return self.result
Solution = CodeforcesTask777BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def spf():
	return map(int, input.readline().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
n = int(input())
x = sorted(list(input()), reverse=True)
y = sorted(list(input()), reverse=True)
(j, k) = (0, 0)
for i in range(n):
	if y[j] >= x[i]:
		j += 1
	if y[k] > x[i]:
		k += 1
print(n - j)
print(k)
endtime = time.time()


n = int(input())
sherlock_card = list(map(int, list(input())))
moriarti_card = list(map(int, list(input())))
count = [0] * 10
for v in moriarti_card:
	count[v] += 1
s_in = 0
for d in sherlock_card:
	beaten = False
	for i in range(10):
		if i >= d and count[i] > 0:
			beaten = True
			count[i] -= 1
			break
	if not beaten:
		s_in += 1
s_out = 0
count = [0] * 10
for v in moriarti_card:
	count[v] += 1
for d in sherlock_card:
	for i in range(10):
		if i > d and count[i] > 0:
			count[i] -= 1
			s_out += 1
			break
print(s_in)
print(s_out)


n = int(input())
sl = input()
mor = input()
arr = [0] * 10
arr2 = [0] * 10
for i in range(n):
	arr[int(mor[i])] += 1
	arr2[int(mor[i])] += 1
k = 0
for i in range(n):
	a = int(sl[i])
	t = False
	for j in range(a, 10):
		if arr[j] > 0:
			arr[j] -= 1
			t = True
			break
	if t == False:
		k += 1
ans = 0
for i in range(n):
	a = int(sl[i])
	for j in range(a + 1, 10):
		if arr2[j] > 0:
			arr2[j] -= 1
			ans += 1
			break
print(k)
print(ans)


def value_index_greater_or_equal_than(ordered_list, number):
	for i in range(0, len(ordered_list)):
		element = ordered_list[i]
		if element >= number:
			return i
	return -1

def minimum_moriartys_flicks(sherlocks_card, sorted_moriarty_card):
	moriartys_flicks = 0
	for digit in sherlocks_card:
		index = value_index_greater_or_equal_than(sorted_moriarty_card, digit)
		if index >= 0:
			sorted_moriarty_card.pop(index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
	return moriartys_flicks

def maximum_sherlocks_flicks(sherlocks_card, sorted_moriarty_card):
	sherlocks_flicks = 0
	for digit in sherlocks_card:
		index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + 1)
		if index >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card.pop(index)
		else:
			sorted_moriarty_card.pop(0)
	return sherlocks_flicks

def solve_old(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_card.sort()
	min_moriartys_flicks = minimum_moriartys_flicks(sherlocks_card, moriartys_card.copy())
	max_sherlocks_flicks = maximum_sherlocks_flicks(sherlocks_card, moriartys_card.copy())
	return (min_moriartys_flicks, max_sherlocks_flicks)

def get_digits_occurrences(card):
	occurrences = {}
	for digit in card:
		digit_occurrences = occurrences.get(digit, 0)
		occurrences[digit] = digit_occurrences + 1
	return occurrences

def find_greater_or_equal_digit(digit, digit_occurrences):
	for i in range(digit, 10):
		occurrences = digit_occurrences.get(i, -1)
		if occurrences > 0:
			return i
	return -1

def find_mimimum_digit(digit_occurrences):
	for i in range(0, 10):
		occurrences = digit_occurrences.get(i, -1)
		if occurrences > 0:
			return i
	return -1

def find_next_moriatys_digit(sherlocks_digit, digit_occurrences):
	digit_found = find_greater_or_equal_digit(sherlocks_digit, digit_occurrences)
	if digit_found >= 0:
		return digit_found
	return find_mimimum_digit(digit_occurrences)

def find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences):
	moriartys_flicks = 0
	for sherlocks_digit in sherlocks_card:
		moriartys_digit = find_next_moriatys_digit(sherlocks_digit, moriartys_digits_occurrences)
		if sherlocks_digit > moriartys_digit:
			moriartys_flicks += 1
		moriartys_digits_occurrences[moriartys_digit] = moriartys_digits_occurrences[moriartys_digit] - 1
	return moriartys_flicks

def find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences):
	sherlocks_flicks = 0
	for sherlocks_digit in sherlocks_card:
		moriartys_digit = find_next_moriatys_digit(sherlocks_digit + 1, moriartys_digits_occurrences)
		if moriartys_digit > sherlocks_digit:
			sherlocks_flicks += 1
		moriartys_digits_occurrences[moriartys_digit] = moriartys_digits_occurrences[moriartys_digit] - 1
	return sherlocks_flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_digits_occurrences = get_digits_occurrences(moriartys_card)
	moriartys_flicks = find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences.copy())
	sherlocks_flicks = find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences.copy())
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


n = int(input())
s = list(map(int, input()))
m = list(map(int, input()))
s.sort()
m.sort()
k = 0
j = 0
for i in range(n):
	if m[i] > s[j]:
		k += 1
		j += 1
N = n
i = 0
j = 0
l = 0
while j < N:
	if m[i] < s[j]:
		N -= 1
		i += 1
		l += 1
	else:
		j += 1
		i += 1
print(l)
print(k)


class var:
	(moriarty, sherlock) = (None, None)
n = int(input())
(sherlock, moriarty) = (sorted(list(str(input()))), sorted(list(str(input()))))
for j in range(n):
	(p_s, p_m) = (0, j)
	(sher, mor) = (0, 0)
	for k in range(n):
		if sherlock[p_s] > moriarty[p_m]:
			mor += 1
		elif sherlock[p_s] < moriarty[p_m]:
			sher += 1
		p_s += 1
		p_m += 1
		p_m %= n
	if var.moriarty == None:
		var.moriarty = mor
	else:
		var.moriarty = min(var.moriarty, mor)
	if var.sherlock == None:
		var.sherlock = sher
	else:
		var.sherlock = max(var.sherlock, sher)
print(var.moriarty)
print(var.sherlock)


def solve():
	input()
	x = list(map(int, list(str(input().rstrip()))))
	y = list(map(int, list(str(input().rstrip()))))
	x.sort()
	y.sort()
	count1 = 0
	i1 = 0
	i2 = 0
	while i1 < len(x) and i2 < len(y):
		if x[i1] > y[i2]:
			count1 += 1
			i2 += 1
		else:
			i2 += 1
			i1 += 1
	print(count1)
	count2 = 0
	i1 = 0
	i2 = 0
	while i1 < len(x) and i2 < len(y):
		if x[i1] >= y[i2]:
			i2 += 1
		else:
			count2 += 1
			i2 += 1
			i1 += 1
	print(count2)
solve()


n = int(input())
a = input()
b = input()
ans = [n, 0]
(M, M2) = ({}, {})
for i in b:
	i = int(i)
	if i in M:
		M[i] += 1
	else:
		M[i] = 1
for i in b:
	i = int(i)
	if i in M2:
		M2[i] += 1
	else:
		M2[i] = 1
for i in a:
	i = int(i)
	for j in range(i, 10):
		if j in M and M[j] > 0:
			M[j] -= 1
			ans[0] -= 1
			break
for i in a:
	i = int(i)
	for j in range(i + 1, 10):
		if j in M2 and M2[j] > 0:
			M2[j] -= 1
			ans[1] += 1
			break
print(ans[0])
print(ans[1])


n = int(input())
s = list(map(int, list(input())))
m = list(map(int, list(input())))
s.sort(reverse=True)
m.sort(reverse=True)
i = 0
j = 0
maxWinMor = 0
while i < n and j < n:
	if m[j] >= s[i]:
		j += 1
		i += 1
		maxWinMor += 1
	else:
		i += 1
i = n - 1
j = n - 1
maxSlapsSher = 0
while i > -1 and j > -1:
	if m[j] > s[i]:
		maxSlapsSher += 1
		i -= 1
		j -= 1
	else:
		j -= 1
print(n - maxWinMor)
print(maxSlapsSher)


N = int(input())
A = [0] * 10
B = [0] * 10
for i in range(2):
	st = input()
	for j in st:
		if (i == 0) & (j != '\n'):
			A[int(j)] += 1
		elif j != '\n':
			B[int(j)] += 1
Am = A[:]
Bm = B[:]
i = 0
j = 0
Sum = 0
while (i < 10) & (j < 10):
	while i < 10:
		if Am[i] == 0:
			i += 1
		else:
			break
	j = i + 1
	while j < 10:
		if Bm[j] == 0:
			j += 1
		else:
			break
	if (j >= 10) | (i >= 10):
		break
	if Am[i] > Bm[j]:
		Sum += Bm[j]
		Am[i] -= Bm[j]
		Bm[j] = 0
	elif Am[i] <= Bm[j]:
		Sum += Am[i]
		Bm[j] -= Am[i]
		Am[i] = 0
mi = 0
i = 9
j = 9
while i >= 0:
	while i >= 0:
		if A[i] == 0:
			i -= 1
		else:
			break
	j = i
	while j < 10:
		if B[j] == 0:
			j += 1
		else:
			break
	if j == 10:
		mi = mi + A[i]
		i = i - 1
	elif A[i] > B[j]:
		A[i] -= B[j]
		B[j] = 0
	elif A[i] <= B[j]:
		B[j] -= A[i]
		A[i] = 0
print(mi)
print(Sum)


import bisect
n = int(input())
S = str(input())
M = str(input())
s = []
m = []
for x in range(len(S)):
	s += [int(S[x])]
	m += [int(M[x])]
min_fl = 0
max_fl = 0
m.sort()
m_c = []
m_c += m
for x in s:
	if bisect.bisect_left(m, x) != len(m):
		del m[bisect.bisect_left(m, x)]
	else:
		min_fl += 1
		del m[m.index(min(m))]
	if bisect.bisect_right(m_c, x) != len(m_c):
		del m_c[bisect.bisect_right(m_c, x)]
		max_fl += 1
	else:
		del m_c[m_c.index(min(m_c))]
print(min_fl)
print(max_fl)


n = int(input())
s = input()
m = input()
sherlock = []
mority = []
for i in range(len(s)):
	sherlock.append(int(s[i]))
for i in range(len(m)):
	mority.append(int(m[i]))
reverseCount = [0] * 11
for i in range(len(sherlock)):
	reverseCount[int(mority[i])] += 1
hits = 0
p = sorted(mority)
for i in range(len(sherlock)):
	j = 0
	while True:
		if int(sherlock[i]) <= int(p[j]):
			hits += 1
			p[j] = -254
			break
		if j < len(p) - 1:
			j += 1
		else:
			break
print(len(sherlock) - hits)
reversehits = 0
for i in range(len(sherlock)):
	j = 1
	while True:
		if reverseCount[int(sherlock[i]) + j] > 0:
			reversehits += 1
			reverseCount[int(sherlock[i]) + j] -= 1
			break
		if int(sherlock[i]) + j < len(reverseCount) - 1:
			j += 1
		else:
			break
print(reversehits)


n = int(input())
s1 = input()
s2 = input()
s1 = list(s1)
s2 = list(s2)
s1.sort()
s2.sort()
ans = 0
j = 0
for i in range(n):
	if int(s2[i]) < int(s1[j]):
		ans += 1
	else:
		j += 1
print(ans)
ans = 0
j = n - 1
for i in range(n - 1, -1, -1):
	if int(s2[j]) > int(s1[i]):
		ans += 1
		j -= 1
	i -= 1
print(ans)


n = int(input())
l = input()
m = input()
a = [0 for _ in range(10)]
b = [0] * 10
for i in range(n):
	a[int(l[i])] += 1
	b[int(m[i])] += 1
c = []
d = []
c.extend(a)
d.extend(b)
f_max = 0
for i in range(10):
	for j in range(i, 10):
		if a[i] > b[j]:
			(a[i], b[j]) = (a[i] - b[j], 0)
		else:
			(a[i], b[j]) = (0, b[j] - a[i])
			break
	for k in range(i + 1, 10):
		if c[i] > d[k]:
			c[i] = c[i] - d[k]
			f_max += d[k]
			d[k] = 0
		else:
			f_max += c[i]
			d[k] = d[k] - c[i]
			break
print(sum(a))
print(f_max)


from collections import defaultdict
n = int(input())
S = input()
M = input()
X = []
Sher = []
Moriarty = defaultdict(int)
MorF = defaultdict(int)
Mor = []
for i in S:
	Sher.append(int(i))
for j in M:
	Moriarty[int(j)] += 1
	MorF[int(j)] += 1
	Mor.append(int(j))
Sher.sort()
Mor.sort()
First = 0
Second = 0
for i in range(n):
	for j in range(Sher[i], 10):
		if MorF[j] > 0:
			First += 1
			MorF[j] -= 1
			break
First = n - First
for i in range(n):
	for j in range(Sher[i] + 1, 10):
		if Moriarty[j] > 0:
			Second += 1
			Moriarty[j] -= 1
			break
print(First)
print(Second)


import math
from decimal import *
import random
n = int(input())
a = list(input())
b = list(input())
for i in range(n):
	a[i] = int(a[i])
	b[i] = int(b[i])
a = sorted(a)
b = sorted(b)
ans1 = 0
ans2 = 0
for i in range(n - 1, -1, -1):
	if b[n - 1 - ans1] > a[i]:
		ans1 += 1
for i in range(n):
	for j in range(n):
		if b[i] >= a[j]:
			a[j] = 10
			ans2 += 1
			break
print(n - ans2)
print(ans1)


import math, sys

def main():
	n = int(input())
	s1 = list(input().strip())
	s2 = list(input().strip())
	sort2 = sorted(s2)
	sort1 = sorted(s1)
	maxs = 0
	j = 0
	for i in range(n):
		while j != n and sort1[i] >= sort2[j]:
			j += 1
		if j == n:
			break
		j += 1
		maxs += 1
	j = 0
	mins = 0
	for i in range(n):
		while j != n and sort1[i] > sort2[j]:
			j += 1
			mins += 1
		if j == n:
			break
		j += 1
	print(mins)
	print(maxs)
main()


n = int(input())
s = str(input())
m = str(input())
marr = [0 for i in range(10)]
marr2 = [0 for i in range(10)]
for i in m:
	marr[int(i)] += 1
	marr2[int(i)] += 1
low = 0
high = 0
for i in s:
	i = int(i)
	b = 0
	for j in range(i, 10):
		if marr[j] > 0:
			marr[j] -= 1
			b = 1
			break
	if b == 0:
		low += 1
for i in s:
	i = int(i)
	for j in range(i + 1, 10):
		if marr2[j] > 0:
			marr2[j] -= 1
			high += 1
			break
print(low)
print(high)


n = int(input())
sher = input()
mor = input()
morD = [0] * 10
for i in mor:
	morD[int(i)] += 1
ans1 = 0
for i in sher:
	k = int(i)
	while k < 10 and morD[k] == 0:
		k += 1
	if k == 10:
		ans1 += 1
		k = 0
		while morD[k] == 0:
			k += 1
	morD[k] -= 1
print(ans1)
morD = [0] * 10
for i in mor:
	morD[int(i)] += 1
ans2 = 0
for i in sher:
	k = int(i)
	if k == 9:
		k = 0
		while morD[k] == 0:
			k += 1
	else:
		k += 1
		while k < 10 and morD[k] == 0:
			k += 1
		if k == 10:
			k = 0
			while morD[k] == 0:
				k += 1
		else:
			ans2 += 1
	morD[k] -= 1
print(ans2)


def BinarySearch(arr, left, right, X):
	while right - left > 1:
		mid = (left + right) // 2
		if arr[mid] > X:
			right = mid
		else:
			left = mid
	if arr[left] > X:
		return left
	elif arr[right] > X:
		return right
	else:
		return 0

def BinarySearch2(arr, left, right, X):
	while right - left > 1:
		mid = (left + right) // 2
		if arr[mid] >= X:
			right = mid
		else:
			left = mid
	if arr[left] >= X:
		return left
	elif arr[right] >= X:
		return right
	else:
		return 0
N = int(input())
A = list(map(int, input()))
B = list(map(int, input()))
B.sort()
C = B.copy()
minimum = 0
maximum = 0
for i in range(N):
	x = B.pop(BinarySearch(B, 0, N - i - 1, A[i]))
	if x > A[i]:
		maximum += 1
for i in range(N):
	x = C.pop(BinarySearch2(C, 0, N - i - 1, A[i]))
	if x < A[i]:
		minimum += 1
print(minimum)
print(maximum)


(n, s, m, max, j) = (int(input()), input(), input(), 0, 0)
(s, m, min) = (sorted(s), sorted(m), n)
for i in m:
	if i >= s[j]:
		(j, min) = (j + 1, min - 1)
j = 0
for i in m:
	if i > s[j]:
		(max, j) = (max + 1, j + 1)
print(min, max, sep='\n')


import sys
import copy
from collections import Counter

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	n = int(input())
	Sn = list(map(int, input()))
	Mn = list(map(int, input()))
	cntM1 = Counter(Mn)
	cntM2 = copy.deepcopy(cntM1)
	maxwin = 0
	for d in Sn:
		for a in range(d + 1, 10):
			if cntM1[a] > 0:
				cntM1[a] -= 1
				maxwin += 1
				break
		else:
			for a in range(0, d + 1):
				if cntM1[a] > 0:
					cntM1[a] -= 1
					break
	minlose = 0
	for d in Sn:
		for a in range(d, 10):
			if cntM2[a] > 0:
				cntM2[a] -= 1
				break
		else:
			for a in range(0, d):
				if cntM2[a] > 0:
					minlose += 1
					cntM2[a] -= 1
					break
	print(minlose)
	print(maxwin)
solve()


n = int(input())
(s, m) = (list(input()), list(input()))
s.sort()
m.sort()
(i, j, c) = (0, 0, 0)
while True:
	if m[i] > s[j]:
		i += 1
		j += 1
		c += 1
	else:
		i += 1
	if i == len(m):
		break
x = 0
for i in range(n):
	if m[i] >= s[x]:
		x += 1
print(n - x)
print(c)


n = int(input())
s = sorted(input())
m = sorted(input())
cnt1 = n
cnt2 = 0
i = 0
j = 0
while i < n and j < n:
	if s[i] <= m[j]:
		cnt1 -= 1
		i += 1
		j += 1
	else:
		j += 1
i = 0
j = 0
while i < n and j < n:
	if s[i] < m[j]:
		cnt2 += 1
		i += 1
		j += 1
	else:
		j += 1
print(cnt1)
print(cnt2)


def value_index_greater_or_equal_than(list, number):
	for i in range(0, len(list)):
		element = list[i]
		if element >= number:
			return i
	return -1

def minimum_moriartys_flicks(sherlocks_card, moriartys_card):
	moriartys_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	for digit in sherlocks_card:
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit)
		if minimum_index >= 0:
			sorted_moriarty_card.pop(minimum_index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
	return moriartys_flicks

def maximum_sherlocks_flicks(sherlocks_card, moriartys_card):
	sherlocks_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	for digit in sherlocks_card:
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + 1)
		if minimum_index >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card.pop(minimum_index)
		else:
			sorted_moriarty_card.pop(0)
	return sherlocks_flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_flicks = minimum_moriartys_flicks(sherlocks_card, moriartys_card)
	sherlocks_flicks = maximum_sherlocks_flicks(sherlocks_card, moriartys_card)
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


import sys
fin = sys.stdin
fout = sys.stdout
n = int(fin.readline())
a = list(fin.readline().strip())
b = list(fin.readline().strip())
can1 = [False] * n
b.sort()
for cur in b:
	for i in range(n):
		if cur >= a[i] and (not can1[i]):
			can1[i] = True
			break
fout.write(str(can1.count(False)) + '\n')
a.sort()
can2 = [False] * n
for cur in b:
	for i in range(n):
		if cur > a[i] and (not can2[i]):
			can2[i] = True
			break
fout.write(str(can2.count(True)))


n = int(input())
sher = input()
mor = input()
morcount = [0] * 10
for mo in mor:
	morcount[int(mo)] += 1
morcount_copy = morcount[:]
mflicks = 0
for sh in sher:
	for i in range(int(sh), 10):
		if morcount[i] != 0:
			morcount[i] -= 1
			break
	else:
		mflicks += 1
		for i in range(0, int(sh)):
			if morcount[i] != 0:
				morcount[i] -= 1
				break
		else:
			exit(-1)
print(mflicks)
morcount = morcount_copy
sflicks = 0
for sh in sher:
	for i in range(int(sh) + 1, 10):
		if morcount[i] != 0:
			morcount[i] -= 1
			sflicks += 1
			break
	else:
		for i in range(0, int(sh) + 1):
			if morcount[i] != 0:
				morcount[i] -= 1
				break
		else:
			exit(-1)
print(sflicks)


n = int(input())
s1 = input()
s2 = input()
d = {}
for i in range(10):
	d[i] = 0
for c in s2:
	d[int(c)] += 1
flicks_saved = 0
for c in s1:
	digit = int(c)
	for i in range(digit, 10):
		if d[i] > 0:
			flicks_saved += 1
			d[i] -= 1
			break
print(n - flicks_saved)
d = {}
for i in range(10):
	d[i] = 0
for c in s2:
	d[int(c)] += 1
flicks_inflicted = 0
for c in s1:
	digit = int(c)
	for i in range(digit + 1, 10):
		if d[i] > 0:
			flicks_inflicted += 1
			d[i] -= 1
			break
print(flicks_inflicted)


def solution():
	n = int(input())
	arr1 = sorted(map(int, list(input())))
	arr2 = sorted(map(int, list(input())))
	i = j = 0
	mi = ma = 0
	for u in arr1:
		while i < n:
			if arr2[i] > u:
				ma += 1
				i += 1
				break
			i += 1
		while j < n:
			if arr2[j] < u:
				j += 1
			else:
				j += 1
				mi += 1
				break
	print(n - mi)
	print(ma)

def main():
	solution()
main()


n = int(input())
s = input()
t = input()
l = list(s)
a = [int(x) for x in l]
l = list(t)
b = [int(x) for x in l]
a = sorted(a)
b = sorted(b)
visited = [0 for i in range(n)]
c1 = 0
c2 = 0
for i in range(n):
	for j in range(n):
		if b[j] > a[i] and (not visited[j]):
			visited[j] = 1
			c2 += 1
			break
visited = [0 for i in range(n)]
for i in range(n):
	for j in range(n):
		if b[j] >= a[i] and (not visited[j]):
			visited[j] = 1
			c1 = c1 + 1
			break
print(n - c1)
print(c2)


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
a.sort()
b.sort()
(x, y) = (0, 0)
for i in range(0, n):
	if b[i] >= a[x]:
		x += 1
	if b[i] > a[y]:
		y += 1
print(n - x)
print(y)


n = int(input())
sc = list(input())
mc = list(input())
sc.sort()
mc.sort()
i = 0
j = 0
avoided = 0
while i < len(mc) and j < len(sc):
	if mc[i] < sc[j]:
		i += 1
	else:
		i += 1
		j += 1
		avoided += 1
min_flicks = n - avoided
i = 0
j = 0
max_flicks = 0
while i < len(mc) and j < len(sc):
	if mc[i] <= sc[j]:
		i += 1
	else:
		i += 1
		j += 1
		max_flicks += 1
print(min_flicks)
print(max_flicks)


n = int(input())
aa = list(map(int, input()))
bb = list(map(int, input()))
aa.sort(reverse=True)
bb.sort(reverse=True)

def solve1():
	a = aa
	b = bb.copy()
	ans = 0
	for aj in a:
		if aj > b[0]:
			ans += 1
			b.pop(-1)
		else:
			i = 0
			for j in range(1, len(b)):
				if aj <= b[j]:
					i = j
				else:
					break
			b.pop(i)
	return ans

def solve2():
	a = aa
	b = bb.copy()
	ans = 0
	for aj in a:
		i = -1
		for j in range(len(b)):
			if aj < b[j]:
				i = j
			else:
				break
		if i >= 0:
			ans += 1
			b.pop(i)
		else:
			b.pop(-1)
	return ans
print(solve1())
print(solve2())


def power(x, y):
	res = 1
	x = x
	while y > 0:
		if y & 1 == 1:
			res = res * x
		y = y >> 1
		x = x * x
	return res
import math
n = int(input())
l1 = list(map(int, input().strip()))
l2 = list(map(int, input().strip()))
l1.sort()
tempS = []
tempS.extend(l1)
l2.sort()
tempM = []
tempM.extend(l2)
count1 = 0
count2 = 0
for i in range(n):
	for j in range(i, n):
		if l1[i] <= l2[j]:
			count2 += 1
			l2[j] = -1
			break
print(n - count2)
i = 0
j = 0
for i in range(n):
	for j in range(i, n):
		if tempS[i] < tempM[j]:
			count1 += 1
			tempM[j] = -1
			break
print(count1)


def value_index_greater_or_equal_than(list, number):
	for i in range(0, len(list)):
		element = list[i]
		if element >= number:
			return i
	return -1

def minimum_moriartys_flicks(sherlocks_card, moriartys_card):
	moriartys_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	for digit in sherlocks_card:
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit)
		if minimum_index >= 0:
			sorted_moriarty_card.pop(minimum_index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
	return moriartys_flicks

def maximum_sherlocks_flicks(sherlocks_card, moriartys_card):
	sherlocks_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	for digit in sherlocks_card:
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + 1)
		if minimum_index >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card.pop(minimum_index)
		else:
			sorted_moriarty_card.pop(0)
	return sherlocks_flicks

def flicks(sherlocks_card, moriartys_card, prefer_no_flicks):
	moriartys_flicks = 0
	sherlocks_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	for digit in sherlocks_card:
		increment = 0 if prefer_no_flicks else 1
		minimum_index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + increment)
		if minimum_index >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card.pop(minimum_index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
	return (moriartys_flicks, sherlocks_flicks)

def solve(number_of_digits, sherlocks_card, moriartys_card):
	(moriartys_flicks, _) = flicks(sherlocks_card, moriartys_card, True)
	(_, sherlocks_flicks) = flicks(sherlocks_card, moriartys_card, False)
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


from sys import stdin
input = lambda : stdin.readline()
from math import ceil, sqrt, gcd
n = int(input())
b = list(map(int, list(input().strip())))
a = list(map(int, list(input().strip())))
d = {}
d1 = {}
a.sort()
b.sort()
for i in range(n):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
	if b[i] in d1:
		d1[b[i]] += 1
	else:
		d1[b[i]] = 1
x = dict(d)
y = dict(d1)
count = 0
for i in a:
	for j in b:
		if i >= j:
			t = min(d[i], d1[j])
			d[i] -= t
			d1[j] -= t
			count += t
print(n - count)
count = 0
a.reverse()
b.reverse()
for i in a:
	for j in b:
		if i > j:
			t = min(x[i], y[j])
			x[i] -= t
			y[j] -= t
			count += t
print(count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

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

def II():
	return int(input())

def LS():
	return input().split()

def S():
	return input()

def main():
	n = II()
	a = [int(c) for c in S()]
	b = [int(c) for c in S()]
	r1 = n
	a.sort()
	b.sort()
	bi = 0
	for c in a:
		while bi < n:
			if c <= b[bi]:
				bi += 1
				r1 -= 1
				break
			bi += 1
	bi = 0
	r2 = 0
	for c in a:
		while bi < n:
			if c < b[bi]:
				bi += 1
				r2 += 1
				break
			bi += 1
	return '{}\n{}'.format(r1, r2)
print(main())


n = int(input())
l1 = list(map(int, input()))
l2 = sorted(map(int, input()))
l22 = l2[:]
(mi, ma) = (0, 0)
jj = 0
for i in range(n):
	for j in range(n):
		if l1[i] <= l22[j]:
			mi += 1
			l22[j] = -1
			break
print(n - mi)
jj = 0
for i in range(n):
	for j in range(jj, n):
		if l1[i] < l2[j]:
			ma += 1
			l2[j] = -1
			break
print(ma)


import sys, math, bisect
from random import randint
inf = float('inf')
mod = 998244353

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors

def isPrime(n, k=5):
	if n < 2:
		return True
	for i in range(0, k):
		a = randint(1, n - 1)
		if pow(a, n - 1, n) != 1:
			return False
	return True
from collections import deque, defaultdict, Counter
import heapq, string
for _ in range(1):
	n = int(input())
	sher = list(input())
	mori = list(input())
	sher = [int(i) for i in sher]
	mori = [int(i) for i in mori]
	mini = mori[:]
	maxi = mori[:]
	mini.sort()
	maxi.sort()
	cnt1 = 0
	cnt2 = 0
	for i in range(n):
		x = sher[i]
		flag = False
		for j in range(n):
			if mini[j] >= x:
				mini[j] = -1
				flag = True
				break
		if not flag:
			cnt1 += 1
	for i in range(n):
		x = sher[i]
		flag = False
		for j in range(n):
			if maxi[j] > x:
				maxi[j] = -1
				flag = True
				cnt2 += 1
				break
	print(cnt1)
	print(cnt2)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
n = inn()
a = [int(x) for x in input()]
b = [int(x) for x in input()]
a.sort()
b.sort()
mxshot = 0
j = 0
for i in range(n):
	if b[i] > a[j]:
		mxshot += 1
		j += 1
mnshot = 0
j = 0
for i in range(n):
	if b[i] >= a[j]:
		j += 1
print(n - j)
print(mxshot)


n = int(input())
s = list(input())
m = list(input())
for i in range(0, n):
	s[i] = int(s[i])
	m[i] = int(m[i])
a = [0] * 10
b = [0] * 10
for i in range(0, n):
	a[m[i]] += 1
	b[m[i]] += 1
s.sort()
count = n
for i in range(0, n):
	temp = s[i]
	for i in range(temp, 10):
		if a[i] > 0:
			count -= 1
			a[i] -= 1
			break
print(count)
count = 0
for i in range(0, n):
	temp = s[i]
	for i in range(temp + 1, 10):
		if b[i] > 0:
			count += 1
			b[i] -= 1
			break
print(count)


n = int(input())
a = sorted(list(map(int, input())))
b = sorted(list(map(int, input())))
used = [0] * n
ans = 0
for i in range(n):
	for j in range(len(b)):
		if not used[j] and a[i] <= b[j]:
			used[j] = 1
			break
	else:
		ans += 1
print(ans)
used = [0] * n
ans = 0
for i in range(n):
	for j in range(len(b)):
		if not used[j] and a[i] < b[j]:
			used[j] = 1
			break
	else:
		continue
	ans += 1
print(ans)


def main():
	n = int(input())
	s = list(map(int, list(input())))
	m = list(map(int, list(input())))
	s = sorted(s)
	m = sorted(m)
	j = 0
	for i in range(n):
		while j < n and s[i] > m[j]:
			j += 1
		if j == n:
			i -= 1
			break
		else:
			j += 1
	ans1 = n - i - 1
	j = 0
	for i in range(n):
		while j < n and s[i] >= m[j]:
			j += 1
		if j == n:
			i -= 1
			break
		else:
			j += 1
	ans2 = i + 1
	print(ans1)
	print(ans2)
main()


n = int(input())
(a, b) = (sorted(input()), sorted(input()))
(i, m) = (0, 0)
for x in b:
	if x >= a[i]:
		i += 1
		m += 1
print(n - m)
(i, m) = (0, 0)
for y in b:
	if y > a[i]:
		i += 1
		m += 1
print(m)


I = input
(x, y, n, A, B) = (0, 0, int(I()), sorted(I()), sorted(I()))
for i in range(n):
	if A[x] <= B[i]:
		x += 1
	if A[y] < B[i]:
		y += 1
print(n - x, y, sep='\n')


n = int(input())
a = list(input())
b = list(input())
for i in range(n):
	a[i] = int(a[i])
	b[i] = int(b[i])
a = sorted(a)
b = sorted(b)
num1 = 0
(i, j) = (0, 0)
while i < n and j < n:
	if a[i] <= b[j]:
		num1 += 1
		i += 1
		j += 1
	else:
		j += 1
i = n - 1
j = n - 1
num2 = 0
while i >= 0 and j >= 0:
	if b[j] > a[i]:
		num2 += 1
		j -= 1
		i -= 1
	else:
		i -= 1
print(n - num1)
print(num2)


def f(s):
	ans = []
	for i in range(len(s)):
		ans.append(int(s[i]))
	return sorted(ans)
n = int(input())
sh = f(input())
m = f(input())
g = m.copy()
for i in range(n):
	for j in range(len(m)):
		if m[j] >= sh[i]:
			m = m[j + 1:]
			break
	else:
		print(n - i)
		break
else:
	print(0)
m = g.copy()
for i in range(n):
	for j in range(len(m)):
		if m[j] > sh[i]:
			m = m[j + 1:]
			break
	else:
		print(i)
		break
else:
	print(n)


import math
n = int(input())
a = sorted(input())
b = sorted(input())
cnt1 = 0
cnt2 = 0
f = [0 for i in range(10)]
g = [0 for i in range(10)]
for i in range(n):
	f[ord(a[i]) - 48] += 1
	g[ord(b[i]) - 48] += 1
for i in range(10):
	p = min(f[i], g[i])
	f[i] -= p
	g[i] -= p
	if g[i]:
		j = i
		while g[i] > 0:
			if j < 0:
				break
			s = min(g[i], f[j])
			g[i] -= s
			f[j] -= s
			j -= 1
cnt1 = sum(f)
i = 0
j = 0
while j < n:
	x = ord(a[i]) - 48
	y = ord(b[j]) - 48
	if y > x:
		i += 1
		cnt2 += 1
	j += 1
print(cnt1)
print(cnt2)


import copy
n = int(input().strip())

def init(n, v):
	s = input().strip()
	for i in range(n):
		v[int(s[i])] += 1

def solve1(n, S, M):
	S = copy.deepcopy(S)
	M = copy.deepcopy(M)
	for i in range(10):
		mi = min(S[i], M[i])
		S[i] -= mi
		M[i] -= mi
	current = 0
	ans = 0
	for i in reversed(range(10)):
		if S[i] > 0:
			if current >= S[i]:
				current -= S[i]
			else:
				ans += S[i] - current
				current = 0
		else:
			current += M[i]
	print(ans)

def solve2(n, S, M):
	current = 0
	ans = 0
	for i in reversed(range(10)):
		if current >= S[i]:
			ans += S[i]
			current -= S[i]
		else:
			ans += current
			current = 0
		current += M[i]
	print(ans)
S = {}
M = {}
for i in range(10):
	S[i] = 0
	M[i] = 0
init(n, S)
init(n, M)
solve1(n, S, M)
solve2(n, S, M)


def getMinMore(index, arr):
	for i in range(index + 1, len(arr)):
		if arr[i] > 0:
			arr[i] -= 1
			return i
	return -1

def getMinEqual(index, arr):
	return getMinMore(index - 1, arr)

def minAns(arr1, arr2):
	ans = 0
	for num in arr1:
		if getMinEqual(num, arr2) == -1:
			ans += 1
	return ans

def maxAns(arr1, arr2):
	ans = 0
	for num in arr1:
		if getMinMore(num, arr2) != -1:
			ans += 1
	return ans
n = int(input())
num1 = int(input())
num2 = int(input())
num1Ds = []
digs = [0 for _ in range(10)]
count = n
while count > 0:
	num1Ds.append(num1 % 10)
	num1 //= 10
	count -= 1
num1Ds.reverse()
count = n
while count > 0:
	digs[int(num2 % 10)] += 1
	num2 //= 10
	count -= 1
digs2 = list(digs)
print(minAns(num1Ds, digs), '\n', maxAns(num1Ds, digs2), sep='')


(n, a, b) = (int(input()), sorted(input()), sorted(input()))
(bi1l, bi1r, v1) = (0, n - 1, 0)
(bi2, v2) = (n - 1, 0)
for x in reversed(a):
	if x > b[bi1r]:
		bi1l += 1
		v1 += 1
	else:
		bi1r -= 1
	if b[bi2] > x:
		bi2 -= 1
		v2 += 1
print(v1, v2, sep='\n')


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
arr1 = sorted(fast())
arr2 = sorted(fast())
(x, y) = (0, 0)
for i in arr2:
	if i >= arr1[x]:
		x += 1
for i in arr2:
	if i > arr1[y]:
		y += 1
print(n - x, y)


N = int(input())
A = list((int(v) for v in list(input())))
B = list((int(v) for v in list(input())))
min_hit = 0
cnt = [0 for i in range(10)]
for v in B:
	cnt[v] += 1
for v in A:
	ok = False
	for i in range(v, 10):
		if cnt[i] > 0:
			ok = True
			cnt[i] -= 1
			break
	if not ok:
		min_hit += 1
		for i in range(0, 10):
			if cnt[i] > 0:
				cnt[i] -= 1
				break
max_hit = 0
cnt = [0 for i in range(10)]
for v in B:
	cnt[v] += 1
for v in A:
	ok = False
	for i in range(v + 1, 10):
		if cnt[i] > 0:
			ok = True
			max_hit += 1
			cnt[i] -= 1
			break
	if not ok:
		for i in range(0, 10):
			if cnt[i] > 0:
				cnt[i] -= 1
				break
print(min_hit, max_hit, sep='\n')


n = int(input())
s = [int(i) for i in input()]
m = [int(i) for i in input()]
s.sort()
m.sort()
min_ans = n
cur = 0
for i in range(n):
	if m[i] >= s[cur]:
		cur += 1
		min_ans -= 1
print(min_ans)
cur = 0
max_ans = 0
for i in range(n):
	if m[i] > s[cur]:
		cur += 1
		max_ans += 1
print(max_ans)


from collections import Counter
n = int(input())
a = [int(x) for x in input()]
b = [int(x) for x in input()]
a.sort(reverse=True)
b.sort(reverse=True)
cur_b = 0
for a_i in a:
	if b[cur_b] > a_i:
		cur_b += 1
punches = 0
cur_b2 = 0
for a_i in a:
	if b[cur_b2] >= a_i:
		cur_b2 += 1
	else:
		punches += 1
print(punches)
print(cur_b)


n = int(input())
n1 = input()
n2 = input()
(l1, l2) = ([int(i) for i in n1], [int(i) for i in n2])
l2.sort()
l3 = l2[:]
m = 0
s = 0
for i in l1:
	l = [j for j in l3 if j > i]
	if l == []:
		l3.remove(min(l3))
	else:
		s += 1
		l3.remove(l[0])
for i in l1:
	l = [j for j in l2 if j == i]
	if l == []:
		l = [j for j in l2 if j > i]
		if l == []:
			m += 1
		else:
			l2.remove(l[0])
	else:
		l2.remove(l[0])
print(m)
print(s)


n = int(input())
a = sorted(list(map(int, input())))
b = sorted(list(map(int, input())))
i = j = 0
q = 0
while j < n:
	while j < n and b[j] <= a[i]:
		j += 1
	q += j < n
	i += 1
	j += 1
i = j = 0
while j < n:
	while j < n and b[j] < a[i]:
		j += 1
	i += 1
	j += 1
w = j - i
print(w, q, sep='\n')


n = int(input())
sher = input()
mor = input()
sherlock = []
moriarty = []
for i in range(len(sher)):
	temp1 = int(sher[i])
	sherlock.append(temp1)
for i in range(len(mor)):
	temp1 = int(mor[i])
	moriarty.append(temp1)
moriarty.sort()
flick1 = 0
flick2 = 0
mortemp = []
for i in range(n):
	temp2 = moriarty[i]
	mortemp.append(temp2)
for i in range(n):
	j = 0
	while j < n:
		temp = sherlock[i]
		if mortemp[j] >= temp:
			mortemp[j] = -1
			i += 1
			break
		else:
			j += 1
	if j == n:
		flick1 += 1
for i in range(n):
	for j in range(n):
		temp = sherlock[i]
		if moriarty[j] > temp:
			flick2 += 1
			moriarty[j] = -1
			i += 1
			break
		else:
			continue
print(flick1)
print(flick2)


(n, s1, s2, c1, c2) = (int(input()), input(), input(), 0, 0)
a = sorted([int(i) for i in s1])
b = sorted([int(i) for i in s2])
j = 0
for i in a:
	while j < n:
		j += 1
		if b[j - 1] >= i:
			c1 += 1
			break
j = 0
for i in a:
	while j < n:
		j += 1
		if b[j - 1] > i:
			c2 += 1
			break
print(n - c1, c2, sep='\n')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l1 = sorted((int(i) for i in si()))
l2 = sorted((int(i) for i in si()))
bl2 = [0] * n
bl1 = [0] * n
for i in range(n):
	for j in range(n):
		if l2[j] >= l1[i] and bl2[j] != 1:
			bl1[i] = 1
			bl2[j] = 1
			break
print(bl1.count(0))
bl1 = [0] * n
bl2 = [0] * n
for i in range(n):
	for j in range(n):
		if l1[i] < l2[j] and bl2[j] != 1:
			bl1[i] = 1
			bl2[j] = 1
			break
print(bl2.count(1))


n = int(input())
(a, b) = (list(input()), list(input()))
a.sort()
b.sort()
(ia, ib, ret_1) = (0, 0, 0)
while ib < n:
	if b[ib] >= a[ia]:
		ia += 1
		ib += 1
	else:
		ib += 1
		ret_1 += 1
print(ret_1)
(ia, ib, ret_2) = (0, 0, 0)
while ib < n:
	if b[ib] > a[ia]:
		ia += 1
		ib += 1
		ret_2 += 1
	else:
		ib += 1
print(ret_2)


n = int(input())
s1 = list(input())
s2 = list(input())
s1.sort()
s2.sort()
cnt = 0
used = [False] * n
ind = 0
for i in range(n):
	for j in range(ind, n):
		if not used[j] and s2[i] >= s1[j]:
			used[j] = True
			ind = j + 1
			cnt += 1
			break
print(n - cnt)
cnt = 0
used = [False] * n
ind = 0
for i in range(n):
	for j in range(ind, n):
		if not used[j] and s1[i] < s2[j]:
			used[j] = True
			ind = j + 1
			cnt += 1
			break
print(cnt)


def main():
	n = int(input())
	sher = [int(c) for c in input().strip()]
	mori = [int(c) for c in input().strip()]
	counts = [0] * 10
	countm = [0] * 10
	for dm in mori:
		countm[dm] += 1
	countdef = 0
	for ds in sher:
		defended = False
		for dm in range(ds, 10):
			if countm[dm] > 0:
				countm[dm] -= 1
				defended = True
				break
		if not defended:
			countdef += 1
			for dm in range(n):
				if countm[dm] > 0:
					countm[dm] -= 1
					break
	print(countdef)
	countdm = [0] * 10
	for dm in mori:
		countm[dm] += 1
	countoff = 0
	for ds in sher:
		attacked = False
		for dm in range(ds + 1, 10):
			if countm[dm] > 0:
				countm[dm] -= 1
				attacked = True
				countoff += 1
				break
		if not attacked:
			for dm in range(n):
				if countm[dm] > 0:
					countm[dm] -= 1
					break
	print(countoff)
main()


import sys
read = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(str(x) + '\n')
N = int(read())
snum = [int(n) for n in read()]
snum.sort()
mnum = [int(n) for n in read()]
mnum.sort()
(mn, mx) = (N, 0)
nidx = 0
for i in range(N):
	for j in range(nidx, N):
		if snum[i] <= mnum[j]:
			mn -= 1
			nidx = j + 1
			break
nidx = 0
for i in range(N):
	for j in range(nidx, N):
		if snum[i] < mnum[j]:
			mx += 1
			nidx = j + 1
			break
write(mn)
write(mx)


import sys
n = int(input())
s = input()
s1 = input()
a = []
b = []
for i in s:
	a.append(int(i))
for j in s1:
	b.append(int(j))
a.sort()
b.sort()
b1 = b[:]
ans2 = 0
ans1 = 0
lst = -1
for i in range(n):
	for j in range(lst + 1, n):
		lst = j
		if a[i] < b[j]:
			b[j] = 0
			ans2 += 1
			break
ans1 = 0
lst = -1
for i in range(n):
	for j in range(lst + 1, n):
		lst = j
		if a[i] <= b1[j]:
			b1[j] = 0
			ans1 += 1
			break
print(n - ans1)
print(ans2)


n = int(input())
a = input()
b = input()
a = sorted(a)
b = sorted(b)
b_arr = []
b_map = {}
b_map_2 = {}
for i in range(0, len(b)):
	if b[i] in b_map:
		b_map[b[i]] += 1
		b_map_2[b[i]] += 1
	else:
		b_arr.append(b[i])
		b_map[b[i]] = 1
		b_map_2[b[i]] = 1
b_index = 0
res_1 = 0
for i in range(0, len(a)):
	while b_index < len(b_arr) and b_arr[b_index] < a[i]:
		b_index += 1
	while b_index < len(b_arr) and b_map[b_arr[b_index]] == 0:
		b_index += 1
	if b_index < len(b_arr):
		res_1 += 1
		b_map[b_arr[b_index]] -= 1
b_index = 0
res_2 = 0
for i in range(0, len(a)):
	while b_index < len(b_arr) and b_arr[b_index] <= a[i]:
		b_index += 1
	while b_index < len(b_arr) and b_map_2[b_arr[b_index]] == 0:
		b_index += 1
	if b_index < len(b_arr):
		res_2 += 1
		b_map_2[b_arr[b_index]] -= 1
print(n - res_1)
print(res_2)


def creditCards(n, sherlock, moriarty):
	s = [int(i) for i in sherlock]
	m = [int(i) for i in moriarty]
	min_flicks_received = 0
	for i in s:
		if i in m:
			m.remove(i)
		elif max(m) < i:
			m.remove(min(m))
			min_flicks_received += 1
		else:
			m.remove(min((j for j in m if j > i)))
	print(min_flicks_received)
	m = [int(i) for i in str(moriarty)]
	max_flicks_given = 0
	for i in s:
		if max(m) <= i:
			m.remove(min(m))
		else:
			m.remove(min((j for j in m if j > i)))
			max_flicks_given += 1
	print(max_flicks_given)
n = int(input())
sherlock = input()
moriarty = input()
creditCards(n, sherlock, moriarty)


mm = input()
for _ in 'sm':
	(ss, mm) = (mm, [0] * 10)
	for d in input():
		mm[57 - ord(d)] += 1
u = v = r = 0
for (s, m) in zip(ss[1:], mm):
	s = min(s, r + m)
	v += s
	r -= s - m
(r, i) = (0, 9)
for (s, m) in zip(ss, mm):
	r += s - m
	u += max(r, 0)
	while 0 < r >= mm[i]:
		r -= mm[i]
		i -= 1
	mm[i] -= r
	r = min(r, 0)
print(f'{u}\n{v}')


import sys
num_digits = input()
s = sys.stdin.readline()
m = sys.stdin.readline()
cnts = [0] * 10
cntm = [0] * 10
num_digits = int(num_digits)
for i in range(0, num_digits):
	cnts[int(s[i])] += 1
	cntm[int(m[i])] += 1
ss = cnts[:]
mm = cntm[:]
ans1 = 0
for i in range(0, 10):
	j = i
	while cnts[i] != 0:
		dist = min(cnts[i], cntm[j])
		cnts[i] -= dist
		cntm[j] -= dist
		if j == 9 and cntm[j] == 0:
			break
		if cntm[j] == 0:
			j += 1
	ans1 += cnts[i]
(cnts, cntm) = (ss, mm)
ans2 = 0
for i in range(0, 10):
	j = i + 1
	while j <= 9 and cnts[i] != 0:
		dist = min(cnts[i], cntm[j])
		cnts[i] -= dist
		cntm[j] -= dist
		ans2 += dist
		if j == 9 and cntm[j] == 0:
			break
		if cntm[j] == 0:
			j += 1
print(ans1, ' ', ans2)


def find_minimum_value_index(list, number):
	for i in range(0, len(list)):
		element = list[i]
		if element >= number:
			return i
	return -1

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_flicks = 0
	sherlocks_flicks = 0
	moriartys_card.sort()
	sorted_moriarty_card = moriartys_card.copy()
	sorted_moriarty_card_alt = moriartys_card.copy()
	for digit in sherlocks_card:
		minimum_index = find_minimum_value_index(sorted_moriarty_card, digit)
		if minimum_index >= 0:
			sorted_moriarty_card.pop(minimum_index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
		minimum_index_alt = find_minimum_value_index(sorted_moriarty_card_alt, digit + 1)
		if minimum_index_alt >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card_alt.pop(minimum_index_alt)
		else:
			sorted_moriarty_card_alt.pop(0)
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


n = int(input())
mass1 = list(map(int, list(input())))
mass2 = list(map(int, list(input())))
mass3 = mass2[:]
kol1 = 0
kol2 = n
for i in range(0, len(mass1)):
	now = mass1[i]
	mass_dif1 = []
	mass_dif2 = []
	for j in range(0, len(mass2)):
		if mass2[j] != -1 and mass2[j] - now > 0:
			mass_dif1.append([mass2[j] - now, j])
		if mass3[j] != -1 and mass3[j] - now >= 0:
			mass_dif2.append([mass3[j] - now, j])
	mass_dif1.sort()
	mass_dif2.sort()
	if len(mass_dif1) > 0:
		mass2[mass_dif1[0][1]] = -1
		kol1 += 1
	if len(mass_dif2) > 0:
		mass3[mass_dif2[0][1]] = -1
		kol2 -= 1
print(kol2)
print(kol1)


def main():
	read = lambda : tuple(map(int, input().split()))
	v = lambda : list(map(int, list(input())))
	n = read()[0]
	(a, b) = (v(), v())
	a.sort()
	b.sort()
	suka = 0
	blya = 0
	xuy = 0
	sukal = []
	for xuy in range(n):
		suka = 0
		for bi in range(0, n - xuy):
			if a[bi] < b[(bi + xuy) % n]:
				suka += 1
		sukal += [suka]
	for i in range(n):
		ch = False
		for bi in range(len(b)):
			if b[bi] >= a[i]:
				ch = True
				break
		if not ch:
			break
		else:
			del b[bi]
			blya += 1
	print(n - blya, max(sukal))
main()


n = int(input())
cnt_b = [0] * 11
cnt_b1 = cnt_b
a = [int(x) for x in input()]
b = [int(x) for x in input()]
a.sort()
b.sort()
(a1, a2) = (0, 0)
for i in range(n):
	if b[i] >= a[a1]:
		a1 += 1
	if b[i] > a[a2]:
		a2 += 1
print(n - a1, a2, sep='\n')


from collections import defaultdict
n = int(input())
a = input()
b = input()
count = defaultdict(lambda : 0)
for i in b:
	count[int(i)] += 1
ans1 = 0
for i in a:
	for j in range(int(i), int(i) + 10):
		if count[j % 10] > 0:
			if j % 10 < int(i):
				ans1 += 1
			count[j % 10] -= 1
			break
count = defaultdict(lambda : 0)
for i in b:
	count[int(i)] += 1
ans2 = 0
for i in a:
	for j in range(int(i) + 1, int(i) + 11):
		if count[j % 10] > 0:
			if j % 10 > int(i):
				ans2 += 1
			count[j % 10] -= 1
			break
print(ans1)
print(ans2)


n = int(input())
s = list(str(input()))
m = list(str(input()))
mcard = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
scard = list(mcard)
for d in m:
	mcard[int(d)] += 1
for s in s:
	scard[int(s)] += 1
mo = list(mcard)
so = list(scard)
min = 0
i = 1
while i < 10:
	if scard[i] >= mcard[i]:
		scard[i] -= mcard[i]
		mcard[i] = 0
	else:
		mcard[i] -= scard[i]
		scard[i] = 0
	i += 1
del i
i = 9
while i > -1:
	if scard[i] == 0:
		i -= 1
		continue
	if i == 9:
		min += scard[i]
		i -= 1
		continue
	j = i
	while j < 10:
		if not mcard[j] == 0:
			if mcard[j] >= scard[i]:
				mcard[j] -= scard[i]
				scard[i] = 0
				break
			else:
				scard[i] -= mcard[j]
				mcard[j] = 0
		j += 1
	min += scard[i]
	i -= 1
print(min)
del min
max = 0
i = 0
while i < 9:
	if so[i] == 0:
		i += 1
		continue
	if so[i] <= mo[i + 1]:
		mo[i + 1] -= so[i]
		max += so[i]
		so[i] = 0
	else:
		so[i] -= mo[i + 1]
		max += mo[i + 1]
		mo[i + 1] = 0
		j = i + 2
		while j < 10:
			if so[i] <= mo[j]:
				mo[j] -= so[i]
				max += so[i]
				so[i] = 0
				break
			else:
				so[i] -= mo[j]
				max += mo[j]
				mo[j] = 0
			j += 1
	i += 1
print(max)
del max


n = int(input())
num1 = input()
num2 = input()
n1 = []
n2 = []
for i in num1:
	n1.append(i)
for i in num2:
	n2.append(i)
n1.sort()
n2.sort()
count = 0
i = 0
k = 0
while i < n and k < n:
	if n1[i] <= n2[k]:
		i += 1
		k += 1
	else:
		k += 1
		count += 1
print(count)
i = n - 1
k = n - 1
count = 0
while i >= 0 and k >= 0:
	if n1[i] < n2[k]:
		count += 1
		k -= 1
		i -= 1
	else:
		i -= 1
print(count)


def ri():
	return map(int, input().split())
n = int(input())
a = input()
b = input()
aa = [int(i) for i in a]
bb = [int(i) for i in b]
aa.sort()
bb.sort()
j = 0
cnt = 0
for i in range(n):
	while j != n and aa[i] > bb[j]:
		j += 1
	if j != n:
		cnt += 1
		j += 1
	else:
		break
print(n - cnt)
j = 0
cnt = 0
for i in range(n):
	while j != n and aa[i] >= bb[j]:
		j += 1
	if j != n:
		cnt += 1
		j += 1
	else:
		break
print(cnt)


n = int(input())
sherlock = []
moriarty = []
s = input()
for i in s:
	sherlock.append(i)
s = input()
for i in s:
	moriarty.append(i)
sher = [0] * 10
for i in sherlock:
	sher[int(i)] += 1
mor = [0] * 10
for i in moriarty:
	mor[int(i)] += 1
sher1 = sher[:]
mor1 = mor[:]
sh = 0
for i in range(10):
	m = min(sher[i], mor[i])
	sher[i] -= m
	mor[i] -= m
	sh += sher[i]
ans1 = 0
z = 0
for i in range(9, -1, -1):
	if mor[i] > sher[i]:
		for j in range(9, -1, -1):
			if mor[i] > 0 and sher[j] > 0:
				m = min(mor[i], sher[j])
				mor[i] -= m
				sher[j] -= m
	elif sher[i] > mor[i]:
		for j in range(10):
			if mor[j] > 0 and sher[i] > 0:
				m = min(mor[j], sher[i])
				mor[j] -= m
				sher[i] -= m
				ans1 += m
mor = mor1
sher = sher1
ans2 = 0
for i in range(10):
	for j in range(i):
		if mor[i] > 0 and sher[j] > 0:
			m = min(mor[i], sher[j])
			ans2 += m
			mor[i] -= m
			sher[j] -= m
print(ans1)
print(ans2)


from sys import stdin
n = int(stdin.readline())
sherlock = [int(x) for x in list(stdin.readline()[:-1])]
moriarty = [int(x) for x in list(stdin.readline()[:-1])]
s1 = sorted(sherlock, reverse=True)
m1 = sorted(moriarty, reverse=True)
count = 0
m1_ptr = 0
for i in range(n):
	if s1[i] > m1[m1_ptr]:
		count += 1
	else:
		m1_ptr += 1
print(count)
count = 0
m1_ptr = 0
for i in range(n):
	if s1[i] < m1[m1_ptr]:
		count += 1
		m1_ptr += 1
print(count)


from collections import Counter
n = int(input())
(s, m) = ([int(x) for x in input()], Counter([int(x) for x in input()]))
m1 = Counter(m)
(ans1, ans2) = (0, 0)
for num1 in sorted([int(x) for x in s]):
	for num2 in range(num1 + 1, 10):
		if m[num2]:
			ans2 += 1
			m[num2] -= 1
			break
	else:
		break
for num1 in sorted(s):
	for num2 in range(num1, 10):
		if m1[num2]:
			ans1 += 1
			m1[num2] -= 1
			break
	else:
		break
print(n - ans1)
print(ans2)


numDigit = int(input())
digitSher = list(map(int, list(input())))
digitMory = list(map(int, list(input())))
digitSher.sort()
digitMory.sort()
(i, j) = (numDigit - 1, numDigit - 1)
(shelban, s) = (0, 0)
while s != j + 1 and i >= 0:
	if digitMory[j] < digitSher[i]:
		s += 1
		shelban += 1
	else:
		j -= 1
	i -= 1
print(shelban)
(j, i) = (0, 0)
while i < numDigit and j < numDigit:
	if digitSher[j] < digitMory[i]:
		j += 1
	i += 1
print(j)


n = int(input())
d = dict()
m = dict()
dv = dict()
ans = 0
ans2 = 0
r = 0
for i in range(10):
	d[i] = 0
	m[i] = 0
	dv[i] = 0
for i in input():
	a = int(i)
	d[a] += 1
	dv[a] += 1
for i in input():
	a = int(i)
	m[a] += 1
for i in range(9, -1, -1):
	t = m[i]
	if t:
		for j in range(i - 1, -1, -1):
			while d[j] > 0:
				if t == 0:
					break
				d[j] -= 1
				t -= 1
				ans2 += 1
for i in range(10):
	t = dv[i]
	for j in range(i, 10):
		while t > 0 and m[j]:
			t -= 1
			m[j] -= 1
			r += 1
		if t == 0:
			break
ans = n - r
print(ans)
print(ans2)


n = int(input())
a = [int(i) for i in list(input())]
b = [int(i) for i in list(input())]
a.sort()
b.sort()
i = 0
j = 0
count = 0
while i < n:
	while j < n and a[i] > b[j]:
		j += 1
	if j < n and a[i] <= b[j]:
		count += 1
		i += 1
		j += 1
	else:
		break
print(n - count)
a.sort()
b.sort()
i = 0
j = 0
count = 0
while i < n:
	while j < n and a[i] >= b[j]:
		j += 1
	if j < n and a[i] < b[j]:
		count += 1
		i += 1
		j += 1
	else:
		break
print(count)


n = int(input())
sher = input()
mor = input()
sher = [int(x) for x in sorted(sher)]
mor = [int(x) for x in sorted(mor)]
sher.reverse()
mor.reverse()
left = 0
right = len(mor) - 1
ans1 = ans2 = 0
for i in range(len(sher)):
	if sher[i] <= mor[left]:
		left += 1
	else:
		right -= 1
		ans1 += 1
left = 0
right = len(mor) - 1
for i in range(len(sher)):
	if sher[i] < mor[left]:
		left += 1
		ans2 += 1
	else:
		right -= 1
print(ans1)
print(ans2)


n = int(input())
x = list(input())
y = list(input())
x.sort()
y.sort()
x.reverse()
y.reverse()
ans1 = 0
ans2 = 0
for i in range(n):
	if y[ans1] >= x[i]:
		ans1 += 1
	if y[ans2] > x[i]:
		ans2 += 1
print(n - ans1)
print(ans2)


from collections import Counter

def losemin(s, m):
	sd = Counter(s)
	md = Counter(m)
	for i in range(10):
		if str(i) in md:
			for j in range(i + 1):
				if str(j) in sd and sd[str(j)] > 0 and (md[str(i)] > 0):
					if sd[str(j)] > md[str(i)]:
						sd[str(j)] = sd[str(j)] - md[str(i)]
						md[str(i)] = 0
					else:
						md[str(i)] = md[str(i)] - sd[str(j)]
						sd[str(j)] = 0
	print(sum(sd.values()))

def winmax(s, m):
	sd = Counter(s)
	md = Counter(m)
	t1 = sum(md.values())
	for i in range(10):
		if str(i) in md:
			for j in range(i):
				if str(j) in sd and sd[str(j)] > 0 and (md[str(i)] > 0):
					if sd[str(j)] > md[str(i)]:
						sd[str(j)] = sd[str(j)] - md[str(i)]
						md[str(i)] = 0
					else:
						md[str(i)] = md[str(i)] - sd[str(j)]
						sd[str(j)] = 0
	print(t1 - sum(md.values()))
n = int(input())
sh = input()
mo = input()
losemin(sh, mo)
winmax(sh, mo)


n = int(input())
sh = sorted(list(map(int, input())))
mo = sorted(list(map(int, input())))
(shflicknum, moflicknum) = (0, n - 1)
for i in range(n - 1, -1, -1):
	if mo[moflicknum] >= sh[i]:
		moflicknum -= 1
print(moflicknum + 1)
for i in range(0, n):
	if mo[i] > sh[shflicknum]:
		shflicknum += 1
print(shflicknum)


def get_digits_occurrences(card):
	occurrences = {}
	for digit in card:
		digit_occurrences = occurrences.get(digit, 0)
		occurrences[digit] = digit_occurrences + 1
	return occurrences

def find_greater_or_equal_digit(digit, digit_occurrences):
	for i in range(digit, 10):
		occurrences = digit_occurrences.get(i, -1)
		if occurrences > 0:
			return i
	return -1

def find_mimimum_digit(digit_occurrences):
	for i in range(0, 10):
		occurrences = digit_occurrences.get(i, -1)
		if occurrences > 0:
			return i
	return -1

def find_next_moriatys_digit(sherlocks_digit, digit_occurrences):
	digit_found = find_greater_or_equal_digit(sherlocks_digit, digit_occurrences)
	if digit_found >= 0:
		return digit_found
	return find_mimimum_digit(digit_occurrences)

def find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences_original):
	moriartys_digits_occurrences = moriartys_digits_occurrences_original.copy()
	moriartys_flicks = 0
	for sherlocks_digit in sherlocks_card:
		moriartys_digit = find_next_moriatys_digit(sherlocks_digit, moriartys_digits_occurrences)
		if sherlocks_digit > moriartys_digit:
			moriartys_flicks += 1
		moriartys_digits_occurrences[moriartys_digit] = moriartys_digits_occurrences[moriartys_digit] - 1
	return moriartys_flicks

def find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences_original):
	moriartys_digits_occurrences = moriartys_digits_occurrences_original.copy()
	sherlocks_flicks = 0
	for sherlocks_digit in sherlocks_card:
		moriartys_digit = find_next_moriatys_digit(sherlocks_digit + 1, moriartys_digits_occurrences)
		if moriartys_digit > sherlocks_digit:
			sherlocks_flicks += 1
		moriartys_digits_occurrences[moriartys_digit] = moriartys_digits_occurrences[moriartys_digit] - 1
	return sherlocks_flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_digits_occurrences = get_digits_occurrences(moriartys_card)
	moriartys_flicks = find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences)
	sherlocks_flicks = find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences)
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


n = int(input())
(s, t) = (list(sorted(input())), list(sorted(input())))
(r1, r2) = (0, 0)
j = 0
k = 0
for i in t:
	if i > s[j]:
		r1 += 1
		j += 1
	if i >= s[k]:
		r2 += 1
		k += 1
print(n - r2)
print(r1)


def main():
	from collections import Counter
	n = int(input())
	s = list(map(int, list(input())))
	m = list(map(int, list(input())))
	m_map = Counter(m)
	flicks = 0
	for i in s:
		played = False
		for j in range(i, 10):
			if m_map[j] > 0:
				played = True
				m_map[j] -= 1
				if i > j:
					flicks += 1
				break
		if not played:
			for j in range(0, i):
				if m_map[j] > 0:
					played = True
					m_map[j] -= 1
					if i > j:
						flicks += 1
					break
	print(flicks)
	m_map = Counter(m)
	flicks = 0
	for i in s:
		played = False
		for j in range(i + 1, 10):
			if m_map[j] > 0:
				played = True
				m_map[j] -= 1
				if j > i:
					flicks += 1
				break
		if not played:
			for j in range(0, i + 1):
				if m_map[j] > 0:
					played = True
					m_map[j] -= 1
					if j > i:
						flicks += 1
					break
	print(flicks)
main()


R = lambda : map(int, input().split())
n = int(input())
base = sorted((int(c) for c in input()))
mutate = sorted((int(c) for c in input()))
(cnt_avoid, cnt_get) = (0, 0)
j = k = 0
for i in range(n):
	while j < n and base[i] > mutate[j]:
		j += 1
	while k < n and base[i] >= mutate[k]:
		k += 1
	cnt_avoid += j == n
	cnt_get += k != n
	j = min(n, j + 1)
	k = min(n, k + 1)
print(cnt_avoid)
print(cnt_get)


def count_digits(string):
	cs = [0] * 10
	for e in string:
		digit = int(e)
		cs[digit] += 1
	return cs
input()
sher = count_digits(input())
mor = count_digits(input())
cur_sum = 0
for i in range(10):
	cur_sum += sher[i]
	cur_sum -= min(cur_sum, mor[i])
print(cur_sum)
cur_sum = 0
max_noogies = 0
for i in range(10):
	this_time = min(mor[i], cur_sum)
	cur_sum -= this_time
	max_noogies += this_time
	cur_sum += sher[i]
print(max_noogies)


import bisect
n = int(input())
sherlock = input()
mori = sorted([int(i) for i in input()])
mori2 = mori.copy()
sherlock_hits = 0
mori_hits = 0
for i in sherlock:
	el = int(i)
	idx = bisect.bisect(mori, el)
	if mori[idx - 1] == el:
		mori.remove(mori[idx - 1])
		continue
	elif idx != len(mori):
		mori.remove(mori[idx])
	else:
		mori_hits += 1
		mori.remove(mori[0])
print(mori_hits)
for i in sherlock:
	el = int(i)
	idx = bisect.bisect(mori2, el)
	if idx != len(mori2):
		mori2.remove(mori2[idx])
		sherlock_hits += 1
	else:
		mori2.remove(mori2[0])
print(sherlock_hits)


def solve(n, sher, mori):
	minimum = 0
	maximum = 0
	moriDig = [0] * 10
	for d in mori:
		moriDig[d] += 1
	dup = moriDig.copy()
	for i in sher:
		notDone = True
		for x in range(i, 10):
			if moriDig[x] > 0:
				notDone = False
				moriDig[x] -= 1
				break
		if notDone:
			minimum += 1
			for x in range(0, i):
				if moriDig[x] > 0:
					moriDig[x] -= 1
					break
	for i in sher:
		notDone = True
		for x in range(i + 1, 10):
			if dup[x] > 0:
				maximum += 1
				dup[x] -= 1
				notDone = False
				break
		if notDone:
			for x in range(0, i):
				if dup[x] > 0:
					dup[x] -= 1
					break
	print(minimum)
	print(maximum)
n = int(input())
s = list(map(int, list(input())))
m = list(map(int, list(input())))
solve(n, s, m)


n = int(input())
a = sorted(list(input()))
b = sorted(list(input()), reverse=True)
cnt1 = [0] * 10
cnt2 = [0] * 10
for i in range(n):
	cnt1[ord(b[i]) - 48] += 1
	cnt2[ord(a[i]) - 48] += 1
A = 0
B = n
for i in range(n):
	k = ord(a[i]) - 48
	for j in range(k + 1, 10):
		if cnt1[j] > 0:
			A += 1
			cnt1[j] -= 1
			break
for i in range(n):
	k = ord(b[i]) - 48
	for j in range(k, -1, -1):
		if cnt2[j] > 0:
			B -= 1
			cnt2[j] -= 1
			break
print(B)
print(A)


n = int(input())
s1 = input()
s2 = input()
st1 = []
st2 = []
for i in range(n):
	st1.append(int(s1[i]))
	st2.append(int(s2[i]))
st2.sort()
st1.sort()
ded1 = []
ded2 = []
d1 = 0
d2 = 0
for i in range(n):
	for j in range(n):
		if st1[j] > st2[j]:
			d1 += 1
		elif st1[j] < st2[j]:
			d2 += 1
	ded1.append(d1)
	ded2.append(d2)
	st2.insert(0, st2[-1])
	st2.pop()
	d1 = 0
	d2 = 0
print(min(ded1))
print(max(ded2))


def solution2():
	n = int(input())
	arr1 = sorted(map(int, input()))
	arr2 = sorted(map(int, input()))
	p1 = p2 = 0
	for i in range(n):
		if arr2[i] > arr1[p1]:
			p1 += 1
		if arr2[i] >= arr1[p2]:
			p2 += 1
	print(n - p2, p1, sep='\n')

def main():
	solution2()
main()


def value_index_greater_or_equal_than(ordered_list, number):
	for i in range(0, len(ordered_list)):
		element = ordered_list[i]
		if element >= number:
			return i
	return -1

def flicks(sherlocks_card, sorted_moriarty_card, prefer_greater_digit):
	moriartys_flicks = 0
	sherlocks_flicks = 0
	for sherlocks_digit in sherlocks_card:
		increment = 1 if prefer_greater_digit else 0
		index = value_index_greater_or_equal_than(sorted_moriarty_card, sherlocks_digit + increment)
		index = index if index >= 0 else 0
		moriartys_digit = sorted_moriarty_card[index]
		if moriartys_digit > sherlocks_digit:
			sherlocks_flicks += 1
		elif moriartys_digit < sherlocks_digit:
			moriartys_flicks += 1
		sorted_moriarty_card.pop(index)
	return (moriartys_flicks, sherlocks_flicks)

def minimum_moriartys_flicks(sherlocks_card, sorted_moriarty_card):
	(moriartys_flicks, _) = flicks(sherlocks_card, sorted_moriarty_card, False)
	return moriartys_flicks

def maximum_sherlocks_flicks(sherlocks_card, sorted_moriarty_card):
	(_, sherlocks_flicks) = flicks(sherlocks_card, sorted_moriarty_card, True)
	return sherlocks_flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_card.sort()
	min_moriartys_flicks = minimum_moriartys_flicks(sherlocks_card, moriartys_card.copy())
	max_sherlocks_flicks = maximum_sherlocks_flicks(sherlocks_card, moriartys_card.copy())
	return (min_moriartys_flicks, max_sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr1 = list(input())
Arr2 = list(input())
first = sorted(Arr1)
second = sorted(Arr2)
i = 0
j = 0
count = 0
while i < n and j < n:
	if first[i] <= second[j]:
		count += 1
		i += 1
		j += 1
	else:
		j += 1
print(n - count)
i = 0
j = 0
count = 0
while i < n and j < n:
	if second[j] > first[i]:
		count += 1
		i += 1
		j += 1
	else:
		j += 1
print(count)


n = int(input())
s = [int(x) for x in input()]
m = [int(x) for x in input()]
marked1 = [False for i in range(n)]
marked2 = marked1.copy()
flicks_g = 0
saves = 0
for i in range(n):
	idx1 = idx2 = -1
	val1 = val2 = 1 << 30
	for j in range(n):
		if m[j] > s[i] and m[j] < val1 and (not marked1[j]):
			idx1 = j
			val1 = m[j]
		if m[j] >= s[i] and m[j] < val2 and (not marked2[j]):
			idx2 = j
			val2 = m[j]
	if idx1 != -1:
		marked1[idx1] = True
		flicks_g += 1
	if idx2 != -1:
		marked2[idx2] = True
		saves += 1
flicks_t = n - saves
print('%d\n%d' % (flicks_t, flicks_g))


import math
import sys
import bisect
from heapq import heapify, heappop, heappush
from itertools import *
from collections import deque, OrderedDict
sys.setrecursionlimit(10 ** 6)
II = lambda : sys.stdin.readline()
inp = lambda : int(II())
inpm = lambda : map(int, II().split())
inpl = lambda : list(inpm())
arr_mn = lambda _n, _m: [[0 for __ in range(_m)] for _ in range(_n)]
arr_nn = lambda _n: arr_mn(_n, _n)
EPS = 1e-09
INF = int(1e+18)
MOD = int(1000000000.0) + 7
N = 2000009

def solve():
	n = inp()
	a = list(map(int, list(input())))
	color = [0 for _ in range(n)]
	b = list(map(int, list(input())))
	d = [0 for _ in range(10)]
	for x in b:
		d[x] += 1
	a.sort(reverse=True)
	b.sort(reverse=True)
	res1 = n
	for i in range(n):
		if d[a[i]] > 0:
			d[a[i]] -= 1
			color[i] = 1
			res1 -= 1
	k = 9
	for i in range(n):
		if not color[i]:
			while k >= 0 and d[k] == 0:
				k -= 1
			if k < 0:
				break
			if a[i] > k:
				continue
			d[k] -= 1
			color[i] = 1
			res1 -= 1
	print(res1)
	res2 = 0
	k = 0
	for i in range(n):
		while k < n and a[k] >= b[i]:
			k += 1
		if k == n:
			break
		res2 += 1
		k += 1
	print(res2)

def main():
	t = 1
	for i in range(t):
		solve()
main()


n = int(input())
sherlock_card = [int(i) for i in input()]
moriati_card = [int(i) for i in input()]
sherlock_card.sort()
moriati_card.sort()
i = 0
moriati_hit = 0
for j in range(n):
	if moriati_card[j] > sherlock_card[i]:
		moriati_hit += 1
		i += 1
	else:
		continue
moriati_hited = 0
sherlock_card.sort(reverse=True)
moriati_card.sort(reverse=True)
i = 0
for j in range(n):
	if sherlock_card[j] > moriati_card[i]:
		moriati_hited += 1
	else:
		i += 1
print(moriati_hited)
print(moriati_hit)


sherlock = [0] * 10
moriarty = [0] * 10
total = int(input())
for x in input():
	sherlock[int(x)] += 1
for x in input():
	moriarty[int(x)] += 1
maximum = 0
c = [0] * 10

def maximum(s, m):
	(sc, mc) = (s[:], m[:])
	m = 0
	for x in range(9):
		val = sc[x]
		while val != 0:
			if x == 9:
				break
			cpy = mc[(x + 1) % 10]
			mc[(x + 1) % 10] = max(0, cpy - val)
			val = max(0, val - cpy)
			x += 1
	print(total - sum(mc))

def minimum(s, m):
	(sc, mc) = (s[:], m[:])
	m = 0
	for x in range(10):
		val = sc[x]
		while val != 0:
			if x == 10:
				break
			cpy = mc[x]
			mc[x] = max(0, cpy - val)
			val = max(0, val - cpy)
			x += 1
	print(sum(mc))
minimum(sherlock, moriarty)
maximum(sherlock, moriarty)


import sys
n = int(input())
sh = list(input())
m = list(input())
sh.sort()
m.sort()
i = 0
j = 0
ans1 = n
while True:
	if j >= n:
		break
	if sh[i] > m[j]:
		j += 1
	else:
		ans1 -= 1
		i += 1
		j += 1
ans2 = 0
i = 0
j = 0
while True:
	if j >= n:
		break
	if sh[i] < m[j]:
		i += 1
		ans2 += 1
		j += 1
	else:
		j += 1
print(ans1)
print(ans2)


u = int(input())
m = [int(k) for k in input()]
l = [int(k) for k in input()]
n = l.copy()
l.sort()
m.sort()
count = 0
for k in m:
	t = 0
	flag = 0
	while t < len(l):
		if l[t] >= k:
			flag = 1
			l.remove(l[t])
			break
		t += 1
	if flag == 0:
		count += 1
print(count)
count = 0
n.sort()
for k in m:
	t = 0
	flag = 0
	while t < len(n):
		if n[t] > k:
			flag = 1
			n.remove(n[t])
			break
		t += 1
	if flag == 1:
		count += 1
print(count)


def ginp():
	return map(int, list(input()))

def lni(m):
	for i in range(len(m)):
		if m[i] != 0:
			return i

def solve(s, m):
	if len(s) == 1:
		return 0
	elif s[-1] > m[-1]:
		s[-1] -= m[-1]
		m[-1] -= m[-1]
		ans = 0
		while s[-1] > 0:
			s[-1] -= 1
			m[lni(m)] -= 1
			ans += 1
		return ans + solve(s[:-1], m[:-1])
	else:
		m[-1] -= s[-1]
		s[-1] -= s[-1]
		m[-2] += m[-1]
		m[-1] = 0
		return solve(s[:-1], m[:-1])
n = input()
sh = input()
mo = input()
sh = [sh.count(str(i)) for i in range(10)]
mo = [mo.count(str(i)) for i in range(10)]
answer = solve(sh[:], mo[:])
print(answer)
ans = 0
for i in range(1, 10):
	while sum(sh) > 0 and lni(sh) < i and (mo[i] > 0):
		sh[lni(sh)] -= 1
		mo[i] -= 1
		ans += 1
print(ans)


n = int(input())
arr1 = sorted(input())
arr2 = sorted(input())
(x, y) = (0, 0)
for i in arr2:
	if i >= arr1[x]:
		x += 1
	if i > arr1[y]:
		y += 1
print(n - x, y)


n = int(input())
sh = input()
mo = sorted(input())
used = [False for _ in range(n)]
count1 = 0
for i in range(n):
	for j in range(n):
		if mo[j] > sh[i] and (not used[j]):
			used[j] = True
			count1 += 1
			break
used = [False for _ in range(n)]
count2 = n
for i in range(n):
	for j in range(n):
		if mo[j] >= sh[i] and (not used[j]):
			used[j] = True
			count2 -= 1
			break
print(count2)
print(count1)


def cards(lst1, lst2):
	(j, lst1, lst2, result) = (len(lst1) - 1, sorted(lst1), sorted(lst2), list())
	for x in range(len(lst1) - 1, -1, -1):
		if lst1[x] <= lst2[j]:
			j -= 1
	result.append(j + 1)
	j = 0
	for x in range(len(lst1)):
		if lst2[x] > lst1[j]:
			j += 1
	result.append(j)
	return result
n = int(input())
a = list(input())
b = list(input())
print(*cards(a, b), sep='\n')


n = int(input())
SherlockCard = list(map(int, input()))
MoriaryCard = list(map(int, input()))
S = 0
M = 0
SherlockCard.sort()
MoriaryCard.sort()
j = 0
for i in range(n):
	if MoriaryCard[i] >= SherlockCard[j]:
		j += 1
	else:
		S += 1
print(S)
j = n - 1
for (i, e) in reversed(list(enumerate(MoriaryCard))):
	if MoriaryCard[j] > SherlockCard[i]:
		M += 1
		j -= 1
print(M)


n = int(input())
a = list(sorted(input()))
b = list(sorted(input()))
ans1 = ans2 = 0
for i in range(n):
	if b[i] >= a[ans1]:
		ans1 += 1
	if b[i] > a[ans2]:
		ans2 += 1
print(n - ans1)
print(ans2)


n = int(input())
s1 = sorted([int(a) for a in input().strip()])
s2 = sorted([int(a) for a in input().strip()])
s2idx = 0
ans = n
for i in range(n):
	while s2idx < n:
		if s1[i] <= s2[s2idx]:
			s2idx += 1
			ans -= 1
			break
		s2idx += 1
	if s2idx >= n:
		break
print(ans)
s2idx = 0
ans = 0
for i in range(n):
	while s2idx < n:
		if s1[i] < s2[s2idx]:
			s2idx += 1
			ans += 1
			break
		s2idx += 1
	if s2idx >= n:
		break
print(ans)


n = int(input())
s = list(map(int, input()))
m = list(map(int, input()))
m.sort()
m1 = list(m)
mor = 0
she = 0
for i in s:
	flick = True
	brk = True
	for j in range(n):
		if m[j] >= i and flick:
			flick = False
			m[j] = -1
		if m1[j] > i and brk:
			she += 1
			m1[j] = -1
			brk = False
	if flick:
		mor += 1
print(mor)
print(she)


(n, s, m, min, max, h1) = (int(input()), input(), input(), 0, 0, [0] * 10)
h2 = [] + h1
for i in m:
	h1[int(i)] += 1
for i in s:
	h2[int(i)] += 1
(p, q) = ([] + h1, [] + h2)
for i in range(10):
	while q[i]:
		for j in range(i, 10):
			if p[j]:
				p[j] -= 1
				break
		else:
			min += 1
			for x in p:
				if x:
					x -= 1
					break
		q[i] -= 1
for i in range(10):
	while h2[i]:
		for j in range(i + 1, 10):
			if h1[j]:
				max += 1
				h1[j] -= 1
				break
		h2[i] -= 1
print(min, max, sep='\n')


n = int(input())
sher = [int(x) for (i, x) in enumerate(input())]
mor = [int(x) for (i, x) in enumerate(input())]
sher.sort()
mor.sort()
(k, res) = (0, 0)
for (i, x) in enumerate(mor):
	if x < sher[k]:
		res += 1
	else:
		k += 1
(res2, k) = (0, 0)
for (i, x) in enumerate(mor):
	if x > sher[k]:
		res2 += 1
		k += 1
print(res)
print(res2)


n = int(input())
ns = [0] * 10
nm = [0] * 10
s = list(map(int, input()))
for i in map(int, input()):
	nm[i] += 1
mi = ma = 0
cnm = nm[:]
for i in s:
	ok = False
	for j in range(i, 10):
		if cnm[j] != 0:
			cnm[j] -= 1
			ok = True
			break
	if not ok:
		mi += 1
cnm = nm[:]
for i in s:
	ok = False
	for j in range(i + 1, 10):
		if cnm[j] != 0:
			cnm[j] -= 1
			ok = True
			break
	if ok:
		ma += 1
print(mi)
print(ma)


n = int(input())
s = [*map(int, input())]
m = [*map(int, input())]
sc = [0] * 10
mc = [0] * 10
for (i, j) in zip(s, m):
	sc[i] += 1
	mc[j] += 1
ans = 0
res = 0
for i in range(10):
	t = sc[i]
	j = i
	while t and j < 10:
		if t - mc[j] >= 0:
			t -= mc[j]
			mc[j] = 0
			j += 1
		else:
			mc[j] -= t
			t = 0
	ans += t
sc = [0] * 10
mc = [0] * 10
for (i, j) in zip(s, m):
	sc[i] += 1
	mc[j] += 1
for i in range(9):
	t = sc[i]
	j = i + 1
	while t and j < 10:
		if t - mc[j] >= 0:
			t -= mc[j]
			mc[j] = 0
			j += 1
		else:
			mc[j] -= t
			t = 0
	res += sc[i] - t
print(ans)
print(res)


n = int(input())
strings = str(input())
stringm = str(input())
strings1 = sorted(strings)
stringm1 = sorted(stringm)
while len(stringm1) > 0:
	c = 0
	while c < len(stringm1):
		if int(strings1[c]) > int(stringm1[c]):
			break
		c = c + 1
	if c == len(stringm1):
		break
	stringm1 = stringm1[:c] + stringm1[c + 1:]
print(n - len(stringm1))
stringm1 = sorted(stringm)
while len(stringm1) > 0:
	c = 0
	while c < len(stringm1):
		if int(strings1[c]) >= int(stringm1[c]):
			break
		c = c + 1
	if c == len(stringm1):
		break
	stringm1 = stringm1[:c] + stringm1[c + 1:]
print(len(stringm1))


n = int(input())
x = str(input())
y = str(input())
x = sorted(x)
y = sorted(y)
i = 0
me = 0
j = 0
while j < n:
	if i >= len(y):
		break
	if y[i] >= x[j]:
		me += 1
		j += 1
	i += 1
print(n - me)
i = 0
you = 0
j = 0
while j < n:
	if i >= len(y):
		break
	if y[i] > x[j]:
		you += 1
		j += 1
	i += 1
print(you)


n = int(input())
sher = input()
mori = input()
temp = [1] * n
tempx = [1] * n
sher = sorted(sher)
mori = sorted(mori)
maximum = 0
minimum = n
for i in range(n):
	for j in range(n):
		if tempx[j] != 0 and mori[j] > sher[i]:
			maximum += 1
			tempx[j] = 0
			break
	for j in range(n):
		if temp[j] != 0 and mori[j] >= sher[i]:
			minimum -= 1
			temp[j] = 0
			break
print(str(minimum) + '\n' + str(maximum))


n = int(input())
s1 = input()
s2 = input()
Sherlock = []
Moriarty = []
for i in range(n):
	Sherlock.append(int(s1[i]))
	Moriarty.append(int(s2[i]))
min1 = 0
count = 0
Sherlock.sort()
Moriarty.sort()
s = m = n - 1
while s != -1:
	if Sherlock[s] <= Moriarty[m]:
		m -= 1
		s -= 1
	else:
		min1 += 1
		s -= 1
s = m = n - 1
while s != -1:
	if Sherlock[s] < Moriarty[m]:
		s -= 1
		m -= 1
		count += 1
	else:
		s -= 1
print(min1)
print(count)


def value_index_greater_or_equal_than(ordered_list, number):
	for i in range(0, len(ordered_list)):
		element = ordered_list[i]
		if element >= number:
			return i
	return -1

def minimum_moriartys_flicks(sherlocks_card, sorted_moriarty_card):
	moriartys_flicks = 0
	for digit in sherlocks_card:
		index = value_index_greater_or_equal_than(sorted_moriarty_card, digit)
		if index >= 0:
			sorted_moriarty_card.pop(index)
		else:
			moriartys_flicks += 1
			sorted_moriarty_card.pop(0)
	return moriartys_flicks

def maximum_sherlocks_flicks(sherlocks_card, sorted_moriarty_card):
	sherlocks_flicks = 0
	for digit in sherlocks_card:
		index = value_index_greater_or_equal_than(sorted_moriarty_card, digit + 1)
		if index >= 0:
			sherlocks_flicks += 1
			sorted_moriarty_card.pop(index)
		else:
			sorted_moriarty_card.pop(0)
	return sherlocks_flicks

def solve_old(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_card.sort()
	min_moriartys_flicks = minimum_moriartys_flicks(sherlocks_card, moriartys_card.copy())
	max_sherlocks_flicks = maximum_sherlocks_flicks(sherlocks_card, moriartys_card.copy())
	return (min_moriartys_flicks, max_sherlocks_flicks)

def get_digits_occurrences(card):
	occurrences = {}
	for digit in card:
		digit_occurrences = occurrences.get(digit, 0)
		occurrences[digit] = digit_occurrences + 1
	return occurrences

def find_greater_or_equal_value(digit, digit_occurrences):
	for i in range(digit, 10):
		occurrences = digit_occurrences.get(i, -1)
		if occurrences > 0:
			return i
	for j in range(0, 10):
		occurrences = digit_occurrences.get(j, -1)
		if occurrences > 0:
			return j
	return -1

def find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences_original):
	moriartys_digits_occurrences = moriartys_digits_occurrences_original.copy()
	moriartys_flicks = 0
	for digit in sherlocks_card:
		value = find_greater_or_equal_value(digit, moriartys_digits_occurrences)
		if digit > value:
			moriartys_flicks += 1
		moriartys_digits_occurrences[value] = moriartys_digits_occurrences[value] - 1
	return moriartys_flicks

def find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences_original):
	moriartys_digits_occurrences = moriartys_digits_occurrences_original.copy()
	sherlocks_flicks = 0
	for digit in sherlocks_card:
		value = find_greater_or_equal_value(digit + 1, moriartys_digits_occurrences)
		if value > digit:
			sherlocks_flicks += 1
		moriartys_digits_occurrences[value] = moriartys_digits_occurrences[value] - 1
	return sherlocks_flicks

def solve(number_of_digits, sherlocks_card, moriartys_card):
	moriartys_digits_occurrences = get_digits_occurrences(moriartys_card)
	moriartys_flicks = find_minimum_moriartys_flicks(sherlocks_card, moriartys_digits_occurrences)
	sherlocks_flicks = find_maximum_sherlocks_flicks(sherlocks_card, moriartys_digits_occurrences)
	return (moriartys_flicks, sherlocks_flicks)
number_of_digits = int(input())
sherlocks_card = [int(x) for x in input()]
moriartys_card = [int(x) for x in input()]
(moriartys_flicks, sherlocks_flicks) = solve(number_of_digits, sherlocks_card, moriartys_card)
print(moriartys_flicks)
print(sherlocks_flicks)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
c = [0] * 11
for i in b:
	c[i] += 1
d = list(c)
s1 = 0
for i in a:
	for j in range(i + 1, 11):
		if c[j] > 0:
			c[j] -= 1
			s1 += 1
			break
s2 = 0
for i in a:
	for j in range(i, 11):
		if d[j] > 0:
			d[j] -= 1
			break
		elif j == 9:
			s2 += 1
print(s2)
print(s1)


amt = int(input())
sherlock = list(input())
moriaty = list(input())
sherlock.sort()
moriaty.sort()
bkp_moriaty = moriaty.copy()
max_sherlock = 0
for i in range(len(sherlock)):
	done = False
	for j in range(len(moriaty)):
		if moriaty[j] > sherlock[i]:
			max_sherlock += 1
			moriaty.pop(j)
			done = True
			break
	if not done:
		for j in range(len(moriaty) - 1, -1, -1):
			if moriaty[j] == sherlock[i]:
				moriaty.pop(j)
				done = True
				break
	if not done:
		moriaty.pop(0)
moriaty = bkp_moriaty
min_moriaty = 0
i = -1
while True:
	i += 1
	if i >= len(sherlock):
		break
	for j in range(len(moriaty) - 1, -1, -1):
		if moriaty[j] == sherlock[i]:
			moriaty.pop(j)
			sherlock.pop(i)
			i -= 1
			break
for i in range(len(sherlock)):
	done = False
	for j in range(len(moriaty)):
		if moriaty[j] > sherlock[i]:
			moriaty.pop(j)
			done = True
			break
	if not done:
		moriaty.pop(0)
		min_moriaty += 1
print(min_moriaty)
print(max_sherlock)


lens = int(input())
sherlock = sorted([x for x in input()])
moriary = sorted([x for x in input()])
canbe_1 = 0
canbe_2 = 0
for i in range(lens):
	if moriary[i] >= sherlock[canbe_1]:
		canbe_1 += 1
	if moriary[i] > sherlock[canbe_2]:
		canbe_2 += 1
print(lens - canbe_1)
print(canbe_2)


n = int(input())
a = sorted(map(int, input()))
b = sorted(map(int, input()))
was = [0] * n
cnt1 = cnt2 = 0
for i in range(n):
	mn = 10
	ind = -1
	for j in range(n):
		if not was[j] and a[j] <= b[i] < mn:
			mn = a[j]
			ind = j
	if ind != -1:
		was[ind] = 1
	else:
		cnt1 += 1
was = [0] * n
for i in range(n):
	mn = 10
	ind = -1
	for j in range(n):
		if not was[j] and a[j] < b[i] < mn:
			mn = a[j]
			ind = j
	if ind != -1:
		was[ind] = 1
		cnt2 += 1
print(cnt1)
print(cnt2)


n = int(input())
a = input()
b = input()
x = sorted(list(a))
y = sorted(list(b))
minm = 0
for i in y:
	for j in range(len(x)):
		if x[j] <= i:
			x.pop(j)
			break
	else:
		minm += 1
print(minm)
x = sorted(list(a))
y = sorted(list(b))
maxm = 0
for i in x:
	for j in range(len(y)):
		if i < y[j]:
			maxm += 1
			y.pop(j)
			break
print(maxm)


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	n = int(input())
	sn = [0] * 10
	mn = sn[:]
	for i in input():
		sn[int(i)] += 1
	for i in input():
		mn[int(i)] += 1
	snc = sn[:]
	mnc = mn[:]
	for i in range(10):
		for j in range(i - 1, -1, -1):
			if mnc[i] == 0:
				break
			tmp = min(mnc[i], snc[j])
			mnc[i] -= tmp
			snc[j] -= tmp
	max_win = n - sum(snc)
	snc = sn[:]
	mnc = mn[:]
	for i in range(10):
		for j in range(i, -1, -1):
			if mnc[i] == 0:
				break
			tmp = min(mnc[i], snc[j])
			mnc[i] -= tmp
			snc[j] -= tmp
	min_lose = sum(snc)
	print(min_lose)
	print(max_win)
solve()


n = int(input())
a = sorted([int(x) for x in input()])
b = sorted([int(x) for x in input()])
(k1, k2) = (0, 0)
for i in range(n):
	if b[i] >= a[k1]:
		k1 += 1
	if b[i] > a[k2]:
		k2 += 1
print(n - k1)
print(k2)


n = int(input())
a = sorted(input())
b = sorted(input())
i = n - 1
j = n - 1
while i >= 0:
	if a[i] <= b[j]:
		i -= 1
		j -= 1
	else:
		i -= 1
print(j + 1)
j = 0
for i in range(n):
	if a[j] < b[i]:
		j += 1
print(j)


from collections import Counter
n = int(input())
num1 = input()
num2 = input()
Sher = list(sorted(num1, reverse=True))
Mor = Counter(map(int, num2))
ans1 = 0
for i in range(n):
	temp = {k for k in Mor.keys() if k >= int(Sher[i])}
	if len(temp) == 0:
		ans1 += 1
	else:
		Mor[min(temp)] -= 1
		if Mor[min(temp)] == 0:
			del Mor[min(temp)]
Mor = Counter(map(int, num2))
ans2 = 0
for i in range(n):
	temp = {k for k in Mor.keys() if k > int(Sher[i])}
	if len(temp) != 0:
		ans2 += 1
		Mor[min(temp)] -= 1
		if Mor[min(temp)] == 0:
			del Mor[min(temp)]
print(ans1, ans2, sep='\n')


n = input()
a = list(sorted(input()))
b = list(sorted(input()))
j = 0
for c in b:
	if c >= a[j]:
		j += 1
print(len(a) - j)
j = 0
for c in b:
	if c > a[j]:
		j += 1
print(j)


n = int(input())
m_flik = 0
s_flik = 0
j = 0
s1 = int(input())
s = []
m1 = int(input())
m = []
for i in range(n):
	s.append(s1 % 10)
	s1 = s1 // 10
for i in range(n):
	m.append(m1 % 10)
	m1 = m1 // 10
s.sort()
m.sort(reverse=True)
m_big = m[j]
for i in range(n - 1, -1, -1):
	if m_big > s[i]:
		m_flik += 1
		j += 1
		if j < n:
			m_big = m[j]
j = 0
m_big = m[j]
for i in range(n - 1, -1, -1):
	if m_big >= s[i]:
		s_flik += 1
		j += 1
		if j < n:
			m_big = m[j]
print(n - s_flik, m_flik)


card_num_length = int(input())
sher = input()
mor = input()
sherlock = []
moriarti_orig = []
for i in sher:
	sherlock.append(int(i))
for i in mor:
	moriarti_orig.append(int(i))
min_shel = len(sherlock)
max_shel = 0
moriarti = sorted(moriarti_orig)
sherlock = sorted(sherlock)
min_equal = max(moriarti)
min_j = -1
for i in range(0, len(sherlock)):
	for j in range(0, len(moriarti)):
		if moriarti[j] >= sherlock[i] and moriarti[j] < min_equal:
			min_equal = moriarti[j]
			min_j = j
	if min_j >= 0:
		moriarti.pop(min_j)
		min_shel -= 1
	elif max(moriarti) >= sherlock[i]:
		min_j = moriarti.index(max(moriarti))
		moriarti.pop(min_j)
		min_shel -= 1
	if len(moriarti) > 0:
		min_j = -1
		min_equal = max(moriarti)
moriarti = sorted(moriarti_orig)
min_max = max(moriarti)
min_j = -1
for i in range(0, len(sherlock)):
	for j in range(0, len(moriarti)):
		if moriarti[j] > sherlock[i] and moriarti[j] < min_max:
			min_max = moriarti[j]
			min_j = j
	if min_j >= 0:
		moriarti.pop(min_j)
		max_shel += 1
	elif max(moriarti) > sherlock[i]:
		min_j = moriarti.index(max(moriarti))
		moriarti.pop(min_j)
		max_shel += 1
	if len(moriarti) > 0:
		min_j = -1
		min_max = max(moriarti)
print(min_shel)
print(max_shel)


n = int(input())
a = input()
b = input()
c = []
c1 = []
for i in a:
	c.append(int(i))
	c1.append(int(i))
d = []
d1 = []
for i in b:
	d.append(int(i))
	d1.append(int(i))
c1 = sorted(c1)
d1 = sorted(d1)
c = sorted(c)
d = sorted(d)
ans = 0
while d:
	if c[0] <= d[0]:
		c.pop(0)
		d.pop(0)
	else:
		d.pop(0)
ans = len(c)
ans_s = 0
while c1 and d1:
	if d1[len(d1) - 1] > c1[len(c1) - 1]:
		ans_s += 1
		d1.pop()
	c1.pop()
print(ans)
print(ans_s)


n = int(input())
a = [int(i) for i in input()]
b = [int(i) for i in input()]
a.sort()
b.sort()
c = a[:]
d = b[:]
f1 = 0
f2 = 0
for _ in range(n):
	if b[-1] > a[-1]:
		del a[-1], b[-1]
	elif b[-1] == a[-1]:
		del a[-1], b[-1]
	else:
		del a[-1], b[0]
		f1 += 1
(a, b) = (c, d)
for _ in range(n):
	if b[-1] > a[-1]:
		del a[-1], b[-1]
		f2 += 1
	else:
		del a[-1], b[0]
print(f1, f2, sep='\n')


from bisect import bisect_left, bisect_right
n = int(input())
sh = sorted(list(input()))
mor = sorted(list(input()))
temp = []
get = 0
for elem in sh:
	a = bisect_left(mor, elem)
	if a >= len(mor):
		get += 1
		a = 0
	temp.append(mor[a])
	mor.pop(a)
mor = sorted(temp)
temp = []
give = 0
for elem in sh:
	a = bisect_right(mor, elem)
	if a < len(mor):
		give += 1
	else:
		a = 0
	mor.pop(a)
print(get, give, sep='\n')


n = int(input())
a = input()
b = input()
hb = [0 for i in range(10)]
for i in range(n):
	hb[ord(b[i]) - ord('0')] += 1
h = list(hb)
fmin = 0
for i in range(n):
	x = ord(a[i]) - ord('0')
	for i in range(10):
		y = (x + i) % 10
		if h[y] > 0:
			h[y] -= 1
			if x > y:
				fmin += 1
			break
h = list(hb)
fmax = 0
for i in range(n):
	x = ord(a[i]) - ord('0')
	for i in range(10):
		y = (x + i + 1) % 10
		if h[y] > 0:
			h[y] -= 1
			if x < y:
				fmax += 1
			break
print(fmin)
print(fmax)


useless = input()

def result(sherlock, moriarty):
	numbers = list()
	for i in range(10):
		numbers.append([sherlock.count(str(i)), moriarty.count(str(i))])
	tmp = 0
	minimum = 0
	i = 1
	while i < 10:
		if numbers[-i][0] - numbers[-i][1] > 0:
			if numbers[-i][0] - numbers[-i][1] - tmp < 0:
				tmp -= numbers[-i][0] - numbers[-i][1]
			else:
				minimum += numbers[-i][0] - numbers[-i][1] - tmp
				tmp = 0
		else:
			tmp += (numbers[-i][0] - numbers[-i][1]) * -1
		i += 1
	i = 1
	win = 0
	tmp = 0
	while i < 10:
		if numbers[-i - 1][0] - numbers[-i][1] - tmp > 0:
			win += numbers[-i][1] + tmp
			tmp = 0
		else:
			win += numbers[-i - 1][0]
			tmp = (numbers[-i - 1][0] - numbers[-i][1] - tmp) * -1
		i += 1
	return (minimum, win)
for i in result(input(), input()):
	print(i)


length = int(input())
justice = [int(n) for n in input()]
cheater = [int(n) for n in input()]
justice.sort()
cheater.sort()
(j_index, cheat_index) = (0, 0)
maximum_ans = 0
while j_index < length and cheat_index < length:
	if justice[j_index] >= cheater[cheat_index]:
		cheat_index += 1
	else:
		j_index += 1
		cheat_index += 1
		maximum_ans += 1
(j_index, cheat_index) = (0, 0)
minimum_ans = 0
while j_index < length and cheat_index < length:
	if justice[j_index] <= cheater[cheat_index]:
		cheat_index += 1
		j_index += 1
		minimum_ans += 1
	elif justice[j_index] > cheater[cheat_index]:
		cheat_index += 1
print(length - minimum_ans)
print(maximum_ans)


n = int(input())
Sh = sorted(input())
Mr = sorted(input())
Sh1 = []
for i in range(n):
	Sh1.append(Sh[i])
min = n
max = 0
for i in range(n):
	for j in range(len(Sh1)):
		if Mr[i] >= Sh1[j]:
			min -= 1
			Sh1.remove(Sh1[j])
			break
for i in range(n):
	for j in range(len(Sh)):
		if Mr[i] > Sh[j]:
			max += 1
			Sh.remove(Sh[j])
			break
print(min)
print(max)


n = int(input())
s = list(map(int, list(input())))
m = list(map(int, list(input())))
m.sort()
m1 = m.copy()
s.sort()
s1 = s.copy()
c = 0
l = 0
for i in range(n):
	for j in range(l, n):
		if m[j] > s[i]:
			c += 1
			m[j] = -1
			s[i] = -1
			l = j
			break
for i in range(n):
	for j in range(n):
		if m1[j] == s1[i]:
			m1[j] = -1
			s1[i] = -1
			break
for i in range(n):
	for j in range(n):
		if m1[j] >= s1[i]:
			m1[j] = -1
			s1[i] = -1
			break
print(n - s1.count(-1))
print(c)


n = int(input())
s = list(input())
a = list((int(x) for x in s))
s = list(input())
b = list((int(x) for x in s))
a.sort()
b.sort()
ans = n
cur = 0
for i in range(0, n):
	if b[i] >= a[cur]:
		ans -= 1
		cur += 1
print(ans)
ans = cur = 0
for i in range(0, n):
	if b[i] > a[cur]:
		ans += 1
		cur += 1
print(ans)


n = int(input())
sherlock = [int(i) for i in list(input())]
moriarty = [int(i) for i in list(input())]
pairs = []
for i in range(n):
	for j in range(n):
		pairs.append((moriarty[j] - sherlock[i], i, j))
pairs = sorted(pairs)
sherlock_marked = [False] * n
moriarty_marked = [False] * n
avoided = 0
for pair in pairs:
	if pair[0] < 0:
		continue
	if not sherlock_marked[pair[1]] and (not moriarty_marked[pair[2]]):
		sherlock_marked[pair[1]] = True
		moriarty_marked[pair[2]] = True
		avoided += 1
sherlock_marked = [False] * n
moriarty_marked = [False] * n
flicked = 0
for pair in pairs:
	if pair[0] < 1:
		continue
	if not sherlock_marked[pair[1]] and (not moriarty_marked[pair[2]]):
		sherlock_marked[pair[1]] = True
		moriarty_marked[pair[2]] = True
		flicked += 1
print(n - avoided)
print(flicked)


n = int(input())
sher = input()
moti = input()
sh = [0] * 10
mt = [0] * 10
for i in range(n):
	sh[int(sher[i])] += 1
	mt[int(moti[i])] += 1
rem = 0
minbeat = 0
for i in range(9, -1, -1):
	if sh[i] <= mt[i]:
		rem += mt[i] - sh[i]
	elif sh[i] <= mt[i] + rem:
		rem -= sh[i] - mt[i]
	else:
		minbeat += sh[i] - (mt[i] + rem)
		rem = 0
print(minbeat)
maxbeat = 0
rem = 0
for i in range(9, 0, -1):
	if sh[i - 1] <= mt[i]:
		maxbeat += sh[i - 1]
		rem += mt[i] - sh[i - 1]
	elif sh[i - 1] <= mt[i] + rem:
		maxbeat += sh[i - 1]
		rem -= sh[i - 1] - mt[i]
	else:
		maxbeat += mt[i] + rem
		rem = 0
print(maxbeat)


n = int(input())
n1 = input()
n2 = input()
a = []
b = []
for i in range(n):
	a.append(int(n1[i]))
	b.append(int(n2[i]))
b.sort()
d = [0] * 10
for i in range(n):
	d[b[i]] += 1
a.sort()
ans1 = ans2 = 0
for i in range(n):
	for j in range(0, 10):
		if j > a[i] and d[j]:
			ans2 += 1
			d[j] -= 1
			flag = 1
			break
for i in range(0, 10):
	d[i] = 0
for i in range(n):
	d[b[i]] += 1
for i in range(n):
	flag = 1
	for j in range(0, 10):
		if j >= a[i] and d[j]:
			flag = 0
			d[j] -= 1
			break
	if flag:
		ans1 += 1
print(ans1)
print(ans2)


n = int(input())
s_n = list(map(int, input()))
m_n = list(map(int, input()))
s_n.sort()
m_n.sort()
(i, j) = (n - 1, n - 1)
while i >= 0:
	if s_n[i] <= m_n[j]:
		j = j - 1
	i = i - 1
print(j + 1)
(i, j) = (0, 0)
while i < n:
	if m_n[i] > s_n[j]:
		j = j + 1
	i = i + 1
print(j)


n = int(input())
c = [int(x) for x in list(input())]
d = [int(x) for x in list(input())]
c.sort()
d.sort()
(i, j, k) = (0, 0, 0)
while i < n and j < n:
	if c[i] <= d[j]:
		i += 1
	else:
		k += 1
	j += 1
print(k)
(i, j, k) = (0, 0, 0)
while i < n and j < n:
	if c[i] < d[j]:
		k += 1
		i += 1
	j += 1
print(k)


from sys import stdin
inp = stdin.readline
n = int(inp())
sherlock = list(inp()[:-1])
moriarty = list(inp()[:-1])
moriarty_freq_min = [0] * 11
moriarty_freq_max = [0] * 11
for i in range(n):
	moriarty_freq_min[int(moriarty[i])] += 1
	moriarty_freq_max[int(moriarty[i])] += 1
moriarty_min = 0
sherlock_max = 0
for i in sherlock:
	i = int(i)
	j = i
	found = False
	while j < 11:
		if moriarty_freq_min[j]:
			moriarty_freq_min[j] -= 1
			found = True
			break
		j += 1
	if not found:
		moriarty_min += 1
	j = i + 1
	found = False
	while j < 11:
		if moriarty_freq_max[j]:
			moriarty_freq_max[j] -= 1
			found = True
			break
		j += 1
	if found:
		sherlock_max += 1
print(moriarty_min)
print(sherlock_max)


n = int(input())
a = list(map(int, list(input())))
b = list(map(int, list(input())))
cnt1 = 10 * [0]
cnt2 = 10 * [0]
b.sort()
for i in range(10):
	cnt1[i] = a.count(i) if i == 0 else a.count(i) + cnt1[i - 1]
	cnt2[9 - i] = a.count(9 - i) if i == 0 else a.count(9 - i) + cnt2[10 - i]
ans1 = ans2 = 0
for num in b:
	if cnt1[num] - ans1 > 0:
		ans1 += 1
	if num and cnt1[num - 1] - ans2 > 0:
		ans2 += 1
print(n - ans1)
print(ans2)


n = int(input())
s = list(map(int, list(input())))
m = map(int, list(input()))
ma = [0] * 10
for dig in m:
	ma[dig] += 1
ma2 = list(ma)
min_f = 0
for nu in s:
	for x in range(nu, 10):
		if ma[x] > 0:
			ma[x] -= 1
			break
	else:
		min_f += 1
		for z in range(len(ma)):
			if ma[z] > 0:
				ma[z] -= 1
				break
print(min_f)
ma = ma2
max_f = 0
for nu in s:
	for x in range(nu + 1, 10):
		if ma[x] > 0:
			ma[x] -= 1
			max_f += 1
			break
	else:
		for z in range(len(ma)):
			if ma[z] > 0:
				ma[z] -= 1
				break
print(max_f)


from sys import stdin
lines = stdin.readlines()
n = int(lines[0])
a = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
b = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
for i in range(n):
	a[int(lines[1][i])] += 1
	b[int(lines[2][i])] += 1

def min_punish(a, b):
	ans = 0
	future_resist = 0
	for number in reversed(range(10)):
		if a[number] - b[number] > future_resist:
			ans += a[number] - b[number] - future_resist
			future_resist = 0
		else:
			future_resist += b[number] - a[number]
	return ans

def max_punish(a, b):
	ans = 0
	for i in range(10):
		min_val = b[i]
		for j in reversed(range(i)):
			if min_val == 0:
				break
			if min_val >= a[j]:
				ans += a[j]
				min_val -= a[j]
				a[j] = 0
			else:
				ans += min_val
				a[j] -= min_val
				min_val = 0
		biggest = 9
		while min_val > 0 and biggest >= 0:
			if a[biggest] >= min_val:
				a[biggest] -= min_val
				min_val = 0
			else:
				min_val -= a[biggest]
				a[biggest] = 0
			biggest -= 1
		b[0] = min_val
	return ans
print(min_punish(a, b))
print(max_punish(a, b))


n = int(input())
sher = str(input())
mor = str(input())
sherd = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
mord = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
sherd2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
mord2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(n):
	if sher[i] == '':
		continue
	s = int(sher[i])
	sherd[s] += 1
	m = int(mor[i])
	mord[m] += 1
for i in range(10):
	sherd2[i] = sherd[i]
	mord2[i] = mord[i]
mins = 0
maxs = 0
for j in range(10):
	i = 9 - j
	diff = sherd[i] - mord[i]
	if diff > 0:
		mins += diff
	elif i > 0:
		mord[i - 1] += -diff
for j in range(9):
	i = 9 - j
	diff = mord2[i] - sherd2[i - 1]
	if diff > 0:
		maxs += sherd2[i - 1]
		if i > 0:
			mord2[i - 1] += diff
	else:
		maxs += mord2[i]
print(mins)
print(maxs)


n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
a.sort()
b.sort()
i = 0
j = 0
while 1:
	if b[j] < a[i]:
		j += 1
	else:
		j += 1
		i += 1
	if i == n or j == n:
		break
print(n - i)
i = 0
j = 0
while 1:
	if b[j] <= a[i]:
		j += 1
	else:
		j += 1
		i += 1
	if i == n or j == n:
		break
print(i)


n = int(input())
s = input()
m = input()
(r, w) = (n, 0)
p = str(s)
o = str(m)
for i in s:
	if i in m:
		r -= 1
		m = m.replace(i, '', 1)
		s = s.replace(i, '', 1)
l = [str(i) for i in range(10)]
for i in s:
	for j in l:
		if i < j and j in m:
			m = m.replace(j, '', 1)
			r -= 1
			break
for i in p:
	for j in l:
		if i < j and j in o:
			o = o.replace(j, '', 1)
			w += 1
			break
print(r, w, sep='\n')


n = int(input())
str_sher = str(input())
str_mor = str(input())
num_sher = [0] * 10
num_mor = [0] * 10
num_sher.append(-1)
num_mor.append(-1)
for s in str_sher:
	num_sher[ord(s) - ord('0')] += 1
for s in str_mor:
	num_mor[ord(s) - ord('0')] += 1

def next_value(nums, p):
	if p > 10:
		return p
	while nums[p] == 0:
		p += 1
	nums[p] -= 1
	return p

def calc_hits(num_sher, num_mor, is_min_strategy):
	shift = 0
	if not is_min_strategy:
		shift = 1
	p_sher = 0
	num = 0
	p_sher = next_value(num_sher, p_sher)
	p_mor = next_value(num_mor, p_sher + shift)
	while p_sher < 10 and p_mor < 10:
		num += p_sher <= p_mor
		p_sher = next_value(num_sher, p_sher)
		p_mor = next_value(num_mor, p_sher + shift)
	if is_min_strategy:
		return n - num
	else:
		return num
print(calc_hits(num_sher.copy(), num_mor.copy(), True))
print(calc_hits(num_sher.copy(), num_mor.copy(), False))


import sys
import math
import collections
from pprint import pprint as pp
mod = 1000000007

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
(n, a, b) = (int(input()), input(), input())
(aa, bb) = (vector(10), vector(10))
for i in range(n):
	aa[ord(a[i]) - ord('0')] += 1
	bb[ord(b[i]) - ord('0')] += 1
sb = [i for i in bb]
ans = 0
indx = 0
for i in a:
	f = False
	for j in range(ord(i) - ord('0'), 10):
		if bb[j] > 0:
			f = True
			bb[j] -= 1
			break
	if f == False:
		while bb[indx] == 0:
			indx += 1
		bb[indx] -= 1
		ans += 1
print(ans)
ans = 0
bb = sb
indx = 0
for i in a:
	f = False
	for j in range(ord(i) - ord('0') + 1, 10):
		if bb[j] > 0:
			f = True
			bb[j] -= 1
			ans += 1
			break
	if f == False:
		while bb[indx] == 0:
			indx += 1
print(ans)


n = int(input())
(sher, mor) = (sorted(input()), sorted(input()))
(x, y) = (0, 0)
for i in range(n):
	if sher[x] <= mor[i]:
		x += 1
	if sher[y] < mor[i]:
		y += 1
print(n - x, y, sep='\n')


n = int(input())
a = list(input())
b = list(input())
a = [int(i) for i in a]
b = [int(i) for i in b]
a.sort()
b.sort()
c = a[:]
d = b[:]
ans1 = 0
ans2 = 0
for i in a:
	for j in range(len(b)):
		if b[j] > i:
			del b[j]
			ans2 += 1
			break
for i in c:
	for j in range(len(d)):
		if d[j] >= i:
			del d[j]
			break
	else:
		ans1 += 1
print(ans1)
print(ans2)


n = int(input())
s = sorted(list(map(int, list(input()))))
m = list(map(int, list(input())))
m.sort()
m1 = 0
m2 = 0
for i in range(n):
	if s[m1] <= m[i]:
		m1 += 1
	if s[m2] < m[i]:
		m2 += 1
print(n - m1)
print(m2)


n = int(input())
a = list(sorted(input()))
b = list(sorted(input()))
j = 0
for i in b:
	if i >= a[j]:
		j += 1
print(len(a) - j)
k = 0
for i in b:
	if i > a[k]:
		k += 1
print(k)


n = int(input())
a = sorted(list(input()))
b = sorted(list(input()))
y = 0
x = 0
j = 0
t = 0
for i in range(n):
	if b[i] >= a[t]:
		t += 1
		x += 1
	if b[i] > a[j]:
		y += 1
		j += 1
print(n - x)
print(y)


import collections
n = int(input())
sh = input()
mor = input()
sh_dig = collections.Counter(sh)
mor_dig = collections.Counter(mor)
sh_sort = sorted(sh)
mor_sort = sorted(mor)
min_strikes = 0
(i, j) = (0, 0)
while j != n:
	if sh_sort[i] <= mor_sort[j]:
		i += 1
		j += 1
	else:
		min_strikes += 1
		j += 1
max_strikes = 0
(i, j) = (0, 0)
while j != n:
	if sh_sort[i] < mor_sort[j]:
		max_strikes += 1
		i += 1
		j += 1
	else:
		j += 1
print(min_strikes)
print(max_strikes)


card_len = int(input()) - 1
sherlock_card = sorted(input())
moriarty_card = sorted(input())
sherlock_flicked = 0
moriarty_flicked = 0
sherlock_index = card_len
moriarty_index = 0
for index in range(len(moriarty_card)):
	while moriarty_index <= card_len and sherlock_card[index] > moriarty_card[moriarty_index]:
		moriarty_index += 1
	if moriarty_index > card_len and moriarty_flicked == 0:
		moriarty_flicked = card_len - index + 1
	moriarty_index += 1
	while sherlock_index >= 0 and sherlock_card[sherlock_index] >= moriarty_card[card_len - index]:
		sherlock_index -= 1
	if sherlock_index >= 0:
		sherlock_flicked += 1
		sherlock_index -= 1
print(moriarty_flicked)
print(sherlock_flicked)


n = int(input())
s1 = input()
s2 = input()
l1 = list(s1)
l2 = list(s2)
l1.sort()
l2.sort()
l1.append(0)
t = 0
x = l1[t]
for i in l2:
	if i >= x:
		t += 1
		x = l1[t]
print(n - t)
f = 0
x = l1[f]
for i in l2:
	if i > x:
		f += 1
		x = l1[f]
print(f)


n = int(input())
o = 0
y = []
q = input()
for i in range(len(q)):
	y.append(int(q[i]))
a = y[:]
y.sort()
v = input()
x = []
for i in range(len(v)):
	x.append(int(v[i]))
b = x[:]
x.sort()
for i in range(len(x)):
	for k in range(len(y)):
		if x[i] > y[k] and y[k] != -1:
			y[k] = -1
			o = o + 1
			break
z = 0
a.sort()
b.sort()
for i in range(len(b)):
	for k in range(len(a)):
		if a[k] <= b[i] and a[k] != -1:
			a[k] = -1
			z = z + 1
			break
print(n - z)
print(o)


def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]
n = read()
S = [ord(c) - ord('1') for c in read(str)]
M = [ord(c) - ord('1') for c in read(str)]
self_knocks = 0
S.sort()
M.sort()
i = n - 1
j = n - 1
while i >= 0:
	if M[j] >= S[i]:
		j -= 1
		i -= 1
	else:
		self_knocks += 1
		i -= 1
op_knocks = 0
i = n - 1
j = n - 1
while i >= 0:
	if M[j] > S[i]:
		j -= 1
		i -= 1
		op_knocks += 1
	else:
		i -= 1
print(self_knocks)
print(op_knocks)


n = int(input())
s = input()
m = input()
m1digits = [0] * 10
m2digits = [0] * 10
for d in m:
	m1digits[int(d)] += 1
	m2digits[int(d)] += 1
ans1 = 0
ans2 = 0
for d in s:
	d = int(d)
	if m1digits[d] > 0:
		m1digits[d] -= 1
	else:
		k = d
		while k < 10 and m1digits[k] == 0:
			k += 1
		if k == 10:
			k = 0
			while m1digits[k] == 0:
				k += 1
			ans1 += 1
		m1digits[k] -= 1
	t = d + 1
	while t < 10 and m2digits[t] == 0:
		t += 1
	if t == 10:
		t = 0
		while m2digits[t] == 0:
			t += 1
		m2digits[t] -= 1
	else:
		ans2 += 1
		m2digits[t] -= 1
print(ans1)
print(ans2)


n = int(input())
s1 = input()
s2 = input()
l = []
l1 = []
for i in range(n):
	l.append(int(s1[i]))
for i in range(len(s2)):
	l1.append(int(s2[i]))
l1.sort()
l.sort()
c = 0
c1 = 0
i = 0
j = 0
while i < len(l) and j < len(l1):
	if l[i] < l1[j]:
		i = i + 1
		j = j + 1
		c = c + 1
	else:
		j = j + 1
i = 0
j = 0
while i < len(l) and j < len(l1):
	if l[i] <= l1[j]:
		i = i + 1
		j = j + 1
	else:
		j = j + 1
		c1 = c1 + 1
print(c1, c)


n = int(input())
sh = list(map(int, input()))
mor = list(map(int, input()))
cnt = [0] * 10
for elem in mor:
	cnt[elem] += 1
cnt2 = cnt[:]
takes = 0
new_mor = [0] * n
for i in range(n):
	ptr = sh[i]
	while ptr < 10 and cnt[ptr] == 0:
		ptr += 1
	if ptr != 10:
		new_mor[i] = ptr
		cnt[ptr] -= 1
	else:
		ptr = 0
		while ptr < 10 and cnt[ptr] == 0:
			ptr += 1
		new_mor[i] = ptr
		cnt[ptr] -= 1
for i in range(n):
	if new_mor[i] < sh[i]:
		takes += 1
gives = 0
new_mor = [0] * n
for i in range(n):
	ptr = sh[i] + 1
	while ptr < 10 and cnt2[ptr] == 0:
		ptr += 1
	if ptr != 10:
		new_mor[i] = ptr
		cnt2[ptr] -= 1
	else:
		ptr = 0
		while ptr < 10 and cnt2[ptr] == 0:
			ptr += 1
		new_mor[i] = ptr
		cnt2[ptr] -= 1
for i in range(n):
	if new_mor[i] > sh[i]:
		gives += 1
print(takes, gives, sep='\n')


n = int(input())
a = input()
b = input()
a1 = list()
for i in range(10):
	a1.append(0)
b1 = list()
for i in range(10):
	b1.append(0)
for k in range(n):
	a1[int(a[k])] += 1
for k in range(n):
	b1[int(b[k])] += 1
i = 9
ans1 = 0
temp = 0
while i >= 0:
	temp += b1[i]
	if a1[i] >= temp:
		ans1 += a1[i] - temp
		temp = 0
	else:
		temp -= a1[i]
	i -= 1
print(ans1)
ans2 = 0
temp = 0
i = 9
while i >= 0:
	if a1[i] <= temp:
		ans2 += a1[i]
		temp -= a1[i]
	else:
		ans2 += temp
		temp = 0
	temp += b1[i]
	i -= 1
print(ans2)


input()
a = sorted(input())
b = sorted(input())
j = 0
for i in b:
	if i >= a[j]:
		j += 1
print(len(a) - j)
j = 0
for i in b:
	if i > a[j]:
		j += 1
print(j)


n = int(input())
a = []
b = []
x = input()
y = input()
for i in range(n):
	a.append(int(x[i]))
for i in range(n):
	b.append(int(y[i]))
i = 0
j = 0
a.sort()
b.sort()
c = 0
d = 0
while i < n and j < n:
	if a[i] <= b[j]:
		c += 1
		i += 1
		j += 1
	else:
		j += 1
i = 0
j = 0
while i < n and j < n:
	if a[i] < b[j]:
		d += 1
		i += 1
		j += 1
	else:
		j += 1
print(n - c)
print(d)


n = int(input())
a = input()
b = input()
sh = []
ma = []
pol = 0
otv = 0
from copy import deepcopy
for i in range(n):
	sh.append(a[i])
	ma.append(b[i])
ma = sorted(ma)
ma1 = deepcopy(ma)
t = False
for i in range(n):
	l = len(ma)
	l1 = len(ma1)
	for j in range(l):
		if ma[j] > sh[i]:
			otv += 1
			ma.pop(j)
			break
	for j1 in range(l1):
		if ma1[j1] >= sh[i]:
			ma1.pop(j1)
			t = True
			break
	if t:
		t = False
	else:
		pol += 1
		ma1.pop(0)
print(pol)
print(otv)


import copy

def bs(temp, x):
	ans = -1
	l = 0
	r = len(temp) - 1
	while l <= r:
		mid = (l + r) // 2
		if temp[mid] >= x:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	if ans != -1:
		ans = temp.pop(ans)
	return ans
t = int(input())
s1 = input()
s2 = [int(i) for i in input()]
s2 = sorted(s2)
temp = copy.copy(s2)
ans = 0
for i in s1:
	if bs(temp, int(i)) != -1:
		continue
	else:
		ans += 1
print(ans)
ans = 0
temp = copy.copy(s2)
for i in s1:
	if bs(temp, int(i) + 1) != -1:
		ans += 1
	else:
		continue
print(ans)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

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

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()
sh = input()
mor = input()
s = []
m = []
for ch in sh:
	s.append(int(ch))
for ch in mor:
	m.append(int(ch))
s.sort()
m.sort()
vis = [False] * n
for i in range(n):
	for j in range(n):
		if s[i] <= m[j] and vis[j] == False:
			vis[j] = True
			break
print(n - sum(vis))
vis = [False] * n
for i in range(n):
	for j in range(n):
		if s[i] < m[j] and vis[j] == False:
			vis[j] = True
			break
print(sum(vis))


n = int(input())
a = sorted(map(int, input()))
b = sorted(map(int, input()))
noMorlick = sherlick = 0
for i in range(n):
	noMorlick += 1 if b[i] >= a[noMorlick] else 0
	sherlick += 1 if b[i] > a[sherlick] else 0
print(n - noMorlick)
print(sherlick)


a = int(input())
b = sorted(input())
c = sorted(input())
x = 0
for i in c:
	if i >= b[x]:
		x += 1
y = 0
for i in c:
	if i > b[y]:
		y += 1
print(a - x, y)


n = int(input())
s = sorted(list(map(int, input())))
m = sorted(list(map(int, input())))
j = 0
min = n
for i in m:
	if i >= s[j]:
		(j, min) = (j + 1, min - 1)
j = 0
max = 0
for i in m:
	if i > s[j]:
		(max, j) = (max + 1, j + 1)
print(min)
print(max)


import sys
s = []
m = []
n = int(input())
s1 = int(input())
m1 = int(input())
for x in range(n):
	s.append(s1 % 10)
	s1 = s1 // 10
	m.append(m1 % 10)
	m1 = m1 // 10
(s.sort(), m.sort())
i = j = 0
for x in range(n):
	if m[x] >= s[i]:
		j = x
		break
k = j
while i < n:
	if j < n:
		if s[i] <= m[j]:
			i += 1
		j += 1
	else:
		break
print(n - i)
(i, j) = (0, k)
while i < n:
	if j < n:
		if s[i] < m[j]:
			i += 1
		j += 1
	else:
		break
print(i)


n = int(input())
s = [int(i) for i in input()]
m = [int(i) for i in input()]
sd = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
md = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(n):
	sd[s[i]] += 1
	md[m[i]] += 1
min_flicks = 0
rest = 0
for i in range(9, -1, -1):
	rest += md[i]
	if sd[i] <= rest:
		rest -= sd[i]
	else:
		min_flicks += sd[i] - rest
		rest = 0
print(min_flicks)
max_flicks = 0
saved = md[9]
for i in range(8, -1, -1):
	if saved >= sd[i]:
		max_flicks += sd[i]
		saved -= sd[i]
		saved += md[i]
	else:
		max_flicks += saved
		saved = md[i]
print(max_flicks)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = int(input())
a = [int(x) for x in input()]
b = [int(x) for x in input()]
b.sort()
save = list(b)
done = set()
ansmin = 0
for x in range(n):
	done = False
	for y in range(len(b)):
		if b[y] >= a[x]:
			b.pop(y)
			done = True
			break
	if done == False:
		ansmin += 1
		b.pop(0)
b = list(save)
ansmax = 0
for x in range(n):
	done = False
	for y in range(len(b)):
		if b[y] > a[x]:
			ansmax += 1
			done = True
			b.pop(y)
			break
	if done == False:
		b.pop(0)
print(ansmin)
print(ansmax)


import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = sorted([int(x) for x in input()])
	m = sorted([int(x) for x in input()])
	j = 0
	k = 0
	for i in range(n):
		if s[j] <= m[i]:
			j += 1
		if s[k] < m[i]:
			k += 1
	print(n - j)
	print(k)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
s = input()
s = list(s)
s = [int(i) for i in s]
m = input()
m = list(m)
m = [int(i) for i in m]
s.sort()
m.sort()
i = 0
j = 0
ans1 = 0
while i < n and j < n:
	if s[i] < m[j]:
		i += 1
		j += 1
	elif s[i] == m[j]:
		i += 1
		j += 1
	else:
		ans1 += 1
		j += 1
i = 0
j = 0
ans2 = 0
while i < n and j < n:
	if s[i] < m[j]:
		ans2 += 1
		i += 1
		j += 1
	else:
		j += 1
print(ans1)
print(ans2)


def solution():
	n = int(input())
	arr1 = [int(x) for x in list(input())]
	arr2 = [int(x) for x in list(input())]
	arr1.sort()
	arr2.sort()
	i = j = 0
	mi = ma = 0
	for u in arr1:
		while i < n:
			if arr2[i] > u:
				ma += 1
				i += 1
				break
			i += 1
		while j < n:
			if arr2[j] < u:
				j += 1
			else:
				j += 1
				mi += 1
				break
	print(f'{n - mi}\n{ma}')

def main():
	solution()
main()


n = int(input())
sher = str(input())
mor = str(input())
sher = list(map(int, sher))
mor = list(map(int, mor))
sher = sorted(sher)
mor = sorted(mor)
sher1 = sher[:]
mor1 = mor[:]
k = 0
for i in range(n):
	if mor1[-1] >= sher1[-1]:
		mor1.pop(-1)
		sher1.pop(-1)
	else:
		k += 1
		mor1.pop(0)
		sher1.pop(-1)
print(k)
k = 0
for i in range(n):
	if mor[-1] > sher[-1]:
		k += 1
		mor.pop(-1)
		sher.pop(-1)
	else:
		mor.pop(0)
		sher.pop(-1)
print(k)


from collections import defaultdict as dc
import sys
import math
mod = 10 ** 9 + 7

def sinp():
	p = str(sys.stdin.readline())
	return p

def seive(n):
	p = [0] * (n + 1)
	for i in range(2, n):
		for j in range(2 * i, n + 1, i):
			p[i] = 1
	return p

def inp():
	p = int(sys.stdin.readline())
	return p

def line():
	p = list(map(int, sys.stdin.readline().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def ind(a):
	return ord(a) - ord('A')

def solve(t):
	n = inp()
	s = list(map(int, input()))
	m = list(map(int, input()))
	m.sort()
	s.sort()
	(i, j) = (0, 0)
	mort = n
	while i < n and j < n:
		if s[i] > m[j]:
			j += 1
		else:
			i += 1
			j += 1
			mort -= 1
	sher = 0
	(i, j) = (0, 0)
	while i < n and j < n:
		if s[i] >= m[j]:
			j += 1
		else:
			i += 1
			j += 1
			sher += 1
	print(mort)
	print(sher)
t = 1
for _ in range(t):
	solve(t)


import bisect
n = int(input())
s = list(input())
t = list(input())
s1 = ''
t1 = ''
for i in range(len(s)):
	s1 += s[i]
	t1 += t[i]
for i in range(len(s)):
	s[i] = int(s[i])
	t[i] = int(t[i])
s = sorted(s)
t = sorted(t)
s1 = sorted(s1)
t1 = sorted(t1)
win = 0
i = 0
while i < len(s):
	j = 0
	while j < len(t):
		if t[j] > s[i]:
			win += 1
			del t[j]
			break
		else:
			j += 1
	i += 1
mark = 0
for i in range(len(t1)):
	k = bisect.bisect_right(s1, t1[i])
	if k - 1 >= 0:
		if t1[i] >= s1[k - 1]:
			mark += 1
			del s1[k - 1]
print(len(s1))
print(win)


n = int(input())
inp = lambda : sorted([*map(int, list(input()))])
(a, b) = (inp(), inp())
ans = ans1 = 0
for i in range(n):
	if b[i] >= a[ans]:
		ans += 1
	if b[i] > a[ans1]:
		ans1 += 1
print(n - ans)
print(ans1)