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: interview

Starter code:

Solutions:
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())
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')

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())
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
#print(marr,marr2)
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
#print(marr,marr2)
for i in s:
    i=int(i)
    for j in range(i+1,10):
        #print(j,marr2[j])
        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)


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)


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)


import math, sys
def main():
	n = int(input())
	s1 = list(input().strip())
	s2 = list(input().strip())
	sort2 = sorted(s2)
	sort1 = sorted(s1)
	#print(sort1)
	#print(sort2)
	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)
	
			
def __starting_point():
	main()

__starting_point()

# Author: Maharshi Gor

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())
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)

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')

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)


#! /usr/bin/python
# kmwho
# Codeforces 401 D2

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
    
    # Defence
    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)

    # Offence
    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
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)

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

# print(mord2)
# print(sherd2)

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)

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())
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)

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())
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)


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()))
    # debug(Sn, locals())

    cntM1 = Counter(Mn)
    cntM2 = copy.deepcopy(cntM1)
    # debug(cntM, locals())

    # max-win
    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

    # min-lose
    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)


def __starting_point():
    solve()
__starting_point()

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):
    nonlocal 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):
    nonlocal 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)


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 = [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));

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)