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

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

ans1 = 0

ans2 = 0

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

        if i in a:

                ans1 += 1



for i in range(x):

        if i in a:

                ans2 += 1

print((min(ans1, ans2)))
n, m, x = list(map(int, input().split()))

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

start = 0

end = 0

for i in range(x):

    if i in A:

        start += 1



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

    if i in A:

        end += 1



print((min(start, end)))
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range(x + 1, n + 1):
    if i in a:
        ans1 += 1
for i in range(x):
    if i in a:
        ans2 += 1
print((min(ans1, ans2)))

n, m, x = list(map(int, input().split()))
A = list(map(int, input().split()))
start = 0
end = 0
for i in range(x):
    if i in A:
        start += 1
for i in range(x, n + 1):
    if i in A:
        end += 1
print((min(start, end)))

-a = list(map(int, input().split())) -ans1 = 0 -ans2 = 0 -for i in range(x + 1, n + 1): -    if i in a: -        ans1 += 1 +A = list(map(int, input().split())) +start = 0 +end = 0 -    if i in a: -        ans2 += 1 -print((min(ans1, ans2))) +    if i in A: +        start += 1 +for i in range(x, n + 1): +    if i in A: +        end += 1 +print((min(start, end)))