n,m,x=list(map(int,input().split()))

gate=list(map(int,input().split()))

cnt1=0

cnt2=0

for i in range(1,x):

    if i in gate:

        cnt1+=1

for j in range(x+1,n):

    if j in gate:

        cnt2+=1

print((min(cnt1,cnt2)))
n,m,x=list(map(int,input().split()))

a=list(map(int,input().split()))

cnt1=0

cnt2=0

for i in range(0,x+1):

    if i in a:

        cnt1+=1

for j in range(x,n+1):

    if j in a:

        cnt2+=1

print((min(cnt1,cnt2)))
n, m, x = list(map(int, input().split()))
gate = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(1, x):
    if i in gate:
        cnt1 += 1
for j in range(x + 1, n):
    if j in gate:
        cnt2 += 1
print((min(cnt1, cnt2)))

n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(0, x + 1):
    if i in a:
        cnt1 += 1
for j in range(x, n + 1):
    if j in a:
        cnt2 += 1
print((min(cnt1, cnt2)))

-gate = list(map(int, input().split())) +a = list(map(int, input().split())) -for i in range(1, x): -    if i in gate: +for i in range(0, x + 1): +    if i in a: -for j in range(x + 1, n): -    if j in gate: +for j in range(x, n + 1): +    if j in a: