f=lambda:[*list(map(int,input().split()))]

n,m,x=f()

a=f()

l=r=0

for i in a:

  if i<x: l+=1

  elif i<n: r+=1

print((min(l,r)))
n,m,x,*a=list(map(int,open(0).read().split()))

print((min(l:=sum(i<x for i in a),m-l)))
f = lambda: [*list(map(int, input().split()))]
n, m, x = f()
a = f()
l = r = 0
for i in a:
    if i < x:
        l += 1
    elif i < n:
        r += 1
print((min(l, r)))

n, m, x, *a = list(map(int, open(0).read().split()))
print((min(l := sum(i < x for i in a), m - l)))

-f = lambda: [*list(map(int, input().split()))] -n, m, x = f() -a = f() -l = r = 0 -for i in a: -    if i < x: -        l += 1 -    elif i < n: -        r += 1 -print((min(l, r))) +n, m, x, *a = list(map(int, open(0).read().split())) +print((min(l := sum(i < x for i in a), m - l)))