There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.
Initially, you are in Square X.
You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.
However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.
It is guaranteed that there is no toll gate in Square 0, Square X and Square N.
Find the minimum cost incurred before reaching the goal.

-----Constraints-----
 - 1 \leq N \leq 100
 - 1 \leq M \leq 100
 - 1 \leq X \leq N - 1
 - 1 \leq A_1 < A_2 < ... < A_M \leq N
 - A_i \neq X
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M X
A_1 A_2 ... A_M

-----Output-----
Print the minimum cost incurred before reaching the goal.

-----Sample Input-----
5 3 3
1 2 4

-----Sample Output-----
1

The optimal solution is as follows:
 - First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.
 - Then, travel from Square 4 to Square 5. This time, no cost is incurred.
 - Now, we are in Square 5 and we have reached the goal.
In this case, the total cost incurred is 1.

Source: atcoder | Difficulty: EASY


Solutions:
import bisect
(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
index = bisect.bisect_left(A, X)
ans = min(M - index, index)
print(ans)


(n, m, x) = map(int, input().split())
a = [int(i) for i in input().split()]
count_1 = 0
for i in range(x):
	if i in a:
		count_1 += 1
count_2 = 0
for i in range(x, n):
	if i in a:
		count_2 += 1
print(min(count_1, count_2))


(n, m, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
cost1 = 0
cost2 = 0
for i in range(x, 0, -1):
	if i in a:
		cost1 += 1
for i in range(x, n):
	if i in a:
		cost2 += 1
cost = [cost1, cost2]
print(min(cost))


def atc_094b(NMX: str, Ai_input: str) -> int:
	(N, M, X) = list(map(int, NMX.split(' ')))
	Ai = [int(ai) for ai in Ai_input.split(' ')]
	up_cost = 0
	down_cost = 0
	for i in range(X + 1, N + 1):
		if i in Ai:
			up_cost += 1
	for i in range(X - 1, 0, -1):
		if i in Ai:
			down_cost += 1
	return min(up_cost, down_cost)
NMX_input_value = input()
Ai_input_value = input()
print(atc_094b(NMX_input_value, Ai_input_value))


(n, m, x) = map(int, input().split())
am = sorted(map(int, input().split()))
print(min(len(list(filter(lambda a: a < x, am))), len(list(filter(lambda a: x < a, am)))))


lst = input().split()
N = int(lst[0])
M = int(lst[1])
X = int(lst[2])
L = input().split()
cost_0 = 0
for n in L:
	if 0 < int(n) < X:
		cost_0 += 1
	elif X < int(n):
		break
cost_N = 0
for n in L:
	if X < int(n) < N:
		cost_N += 1
print(min([cost_0, cost_N]))


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


import sys
input = sys.stdin.readline

def main():
	(n, m, x) = map(int, input().split())
	maps = []
	maps = list(map(int, input().split()))
	dp = [0] * (n + 1)
	left = 0
	right = 0
	for i in maps:
		dp[i] = 1
	left = sum(dp[x:])
	right = sum(dp[:x])
	print(min(left, right))

def __starting_point():
	main()
__starting_point()


import sys
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
(n, m, x) = [int(num) for num in lines.pop(0).split(' ')]
a_list = [int(num) for num in lines.pop(0).split(' ')]
for i in range(m):
	if a_list[i] > x:
		break
ans = min(i, m - i)
print(ans)


(total_square, total_toll_gate, current_square) = map(int, input().split())
toll_gate_square = list(map(int, input().split()))
route1 = 0
route2 = 0
for i in range(total_toll_gate):
	if toll_gate_square[i] < current_square:
		route1 += 1
	else:
		route2 += 1
print(min(route1, route2))


(N, M, X) = list(map(int, input().split()))
my_list = list(map(int, input().split(maxsplit=M)))
count_start = 0
count_goal = 0
for i in range(1, X):
	if i in my_list:
		count_start += 1
for i in range(X, N):
	if i in my_list:
		count_goal += 1
if count_start >= count_goal:
	answer = count_goal
else:
	answer = count_start
print(answer)


(n, m, x) = map(int, input().split())
A = list(map(int, input().split()))
print(min(sum([a < x for a in A]), sum([a > x for a in A])))


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


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
X_high = 0
X_low = 0
for i in range(X, N + 1):
	if i in A:
		X_high += 1
for i in range(0, X + 1):
	if i in A:
		X_low += 1
print(min(X_high, X_low))


(N, M, X) = map(int, input().split())
Ai = list(map(int, input().split()))
goto_0 = 0
goto_N = 0
for i in range(X, 0, -1):
	if i in Ai:
		goto_0 += 1
for i in range(X, N):
	if i in Ai:
		goto_N += 1
print(min(goto_0, goto_N))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
l1 = []
l2 = []
for i in A:
	if X > i:
		l1.append(i)
	else:
		l2.append(i)
print(min(len(l1), len(l2)))


def tool_gate(now: int, gate_list: list) -> int:
	back_count = sum((i < now for i in gate_list))
	forward_count = sum((i > now for i in gate_list))
	return min(back_count, forward_count)

def __starting_point():
	(n, m, now) = list(map(int, input().split()))
	gate_list = list(map(int, input().split()))
	print(tool_gate(now, gate_list))
__starting_point()


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
start = sum((i > x for i in a))
end = sum((i < x for i in a))
print(min(start, end))


import sys
input = sys.stdin.readline
(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
if A[int(M / 2)] > X:
	b = [i for i in A if i < X]
else:
	for i in A[::-1]:
		b = [i for i in A if i > X]
print(min(len(b), M - len(b)))


(last, fee, cur) = map(int, input().split())
feesqu = list(map(int, input().split()))
total = len(feesqu)
tcost = 0
gcost = 0
for cnt in range(0, total, 1):
	if feesqu[cnt] < cur:
		tcost += 1
gcost = total - tcost
print(min(tcost, gcost))


(N, M, X) = list(map(int, input().split()))
a_point = list(map(int, input().split()))
lg = 0
sl = 0
for i in range(len(a_point)):
	if X < a_point[i]:
		lg += 1
	else:
		sl += 1
if lg > sl:
	print(sl)
else:
	print(lg)


(N, M, X) = map(int, input().split())
fee = list(map(int, input().split()))
result_1 = []
result_2 = []
for i in fee:
	if i > X:
		result_1.append(i)
	else:
		result_2.append(i)
result = min(len(result_1), len(result_2))
print(result)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in a:
	if i < x:
		ans += 1
	else:
		break
print(min(ans, m - ans))


import bisect

def answer(n: int, m: int, x: int, a: []) -> int:
	i = bisect.bisect_left(a, x)
	return min(i, len(a) - i)

def main():
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(answer(n, m, x, a))

def __starting_point():
	main()
__starting_point()


(N, M, X) = [int(i) for i in input().split()]
AS = [int(i) for i in input().split()]
cnt1 = 0
for i in range(0, X):
	if i in AS:
		cnt1 += 1
cnt2 = 0
for i in range(X + 1, N + 1):
	if i in AS:
		cnt2 += 1
print(cnt1 if cnt1 < cnt2 else cnt2)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
goto_goal_0 = 0
goto_goal_n = 0
for i in range(x - 1, 0, -1):
	if i in a:
		goto_goal_0 += 1
for i in range(x, n + 1):
	if i in a:
		goto_goal_n += 1
if goto_goal_0 < goto_goal_n:
	print(goto_goal_0)
else:
	print(goto_goal_n)


(N, M, X) = map(int, input().split())
A = map(int, input().split())
L = 0
R = 0
for ai in A:
	if ai < X:
		L = L + 1
	else:
		R = R + 1
print(min(L, R))


import sys
input = sys.stdin.readline
(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
count = 0
if A[int(M / 2)] > X:
	for i in A:
		if i < X:
			count += 1
		else:
			break
else:
	for i in A[::-1]:
		if i > X:
			count += 1
		else:
			break
print(min(count, M - count))


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
right = [int(i) for i in A if i > X]
left = [int(i) for i in A if i < X]
r = len(right)
l = len(left)
if r < l:
	print(r)
else:
	print(l)


a = [int(c) for c in input().split()]
N = a[0]
M = a[1]
X = a[2]
A = [int(c) for c in input().split()]
A2 = [0] * (N + 1)
for i in range(M):
	A2[A[i]] = 1
cnt = X
cost1 = 0
while cnt < N + 1:
	cost1 += A2[cnt]
	cnt += 1
cnt = X
cost2 = 0
while cnt > 0:
	cost2 += A2[cnt]
	cnt -= 1
if cost1 < cost2:
	print(cost1)
else:
	print(cost2)


a = input().split()
N = int(a[0])
M = int(a[1])
X = int(a[2])
ryokinjo = []
b = input().split()
for i in range(len(b)):
	ryokinjo.append(int(b[i]))
count1 = 0
count2 = 0
for i in range(len(ryokinjo)):
	if ryokinjo[i] < X:
		count1 += 1
	if ryokinjo[i] > X:
		count2 += 1
print(min([count1, count2]))


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = list(map(int, input().split()))
e = 0
f = 0
for i in range(b):
	if d[i] > c:
		e = e + 1
	if d[i] < c:
		f = f + 1
if e > f:
	print(f)
else:
	print(e)


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
cnt = len([a for (a, i) in enumerate(A) if i >= X])
cnt = min(cnt, M - cnt)
print(cnt)


(n, m, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
x1 = x
x2 = x
while x1 < n + 1:
	x1 += 1
	if x1 in a:
		cnt1 += 1
while x2 > 0:
	x2 -= 1
	if x2 in a:
		cnt2 += 1
if cnt1 < cnt2:
	ans = cnt1
else:
	ans = cnt2
print(ans)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
acc = [0] * (n + 1)
for i in a:
	acc[i] = 1
print(min(sum(acc[:x]), sum(acc[x:])))


(num, count_station, my_position) = list(map(int, input().split()))
a = list(map(int, input().split()))
station_list = list(a)
space = num + 1
first_me_cost = 0
last_me_cost = 0
distance_me_first = my_position
distance_me_last = num - my_position
for i in station_list:
	if 1 <= i <= my_position - 1:
		first_me_cost += 1
for i in station_list:
	if my_position + 1 <= i < num:
		last_me_cost += 1
if first_me_cost > last_me_cost:
	print(last_me_cost)
elif last_me_cost > first_me_cost:
	print(first_me_cost)
elif last_me_cost == first_me_cost:
	print(first_me_cost)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
c = x
ans = 0
ans1 = 0
while c:
	ans += c in a
	c -= 1
while x < n:
	ans1 += x in a
	x += 1
print(min(ans, ans1))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = sorted(A)
C = [0] * (N + 1)
cnt_1 = 0
cnt_2 = 0
for i in range(M):
	C[B[i]] += 1
for j in range(1, N - X):
	cnt_1 += C[X + j]
for k in range(1, X + 1):
	cnt_2 += C[X - k]
cnt = [cnt_1, cnt_2]
print(min(cnt))


(n, m, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
k = n - 1
for i in range(m):
	if a[i] > x:
		k = i
		break
if k == 0 or k == n - 1:
	print('0')
	return
else:
	print(min(k, m - k))


S_list = [input() for i in range(2)]
(N, M, X) = map(int, S_list[0].split())
A_list = list(map(int, S_list[1].split()))
A_goal_N = [i for i in A_list if X < i and i < N]
A_goal_0 = [i for i in A_list if 0 < i and i < X]
result = min(len(A_goal_N), len(A_goal_0))
print(result)


(N, M, X, *A) = map(int, open(0).read().split())
l = [0] * N
for a in A:
	l[a - 1] = 1
print(min(sum(l[:X]), sum(l[X:])))


(n, m, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
goal_0 = 0
goal_1 = 0
for i in range(x, 0, -1):
	if i in a:
		goal_0 += 1
for i in range(x, n + 1, 1):
	if i in a:
		goal_1 += 1
if goal_0 < goal_1:
	print(goal_0)
else:
	print(goal_1)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
p = 0
q = 0
for i in a:
	if i > x:
		p += 1
	elif i < x:
		q += 1
print(min(p, q))


(n, m, x) = map(int, input().split())
List = [int(i) for i in input().split()]
lcost = 0
rcost = 0
for a in List:
	if a < x:
		lcost += 1
for b in List:
	if b > x:
		rcost += 1
print(min(lcost, rcost))


(n, m, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
c0 = 0
cN = 0
for A in a:
	if A > x:
		cN += 1
	elif A < x:
		c0 += 1
print(min(c0, cN))


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

def answer(n: int, m: int, x: int, a: list) -> int:
	left = 0
	right = 0
	for i in a:
		if i < x:
			left += 1
		else:
			right += 1
	return min(left, right)
print(answer(n, m, x, a))


(N, M, X) = map(int, input().split())
L = list(map(int, input().split()))
s = 0
b = 0
for i in L:
	if i > X:
		s += 1
	else:
		b += 1
if s >= b:
	print(b)
else:
	print(s)


(N, M, X) = list(map(int, input().split()))
S = list(map(int, input().split()))
Fees = list(S)
Goal1 = []
Goal2 = []
count1 = 0
count2 = 0
point0 = 0
for i in range(X):
	point0 += 1
	Goal1.append(point0)
for j in range(N - X):
	X += 1
	Goal2.append(X)
for fee in Fees:
	if fee in Goal1:
		count1 += 1
	if fee in Goal2:
		count2 += 1
if count1 >= count2:
	print(count2)
if count1 < count2:
	print(count1)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
r = 0
l = 0
for i in a:
	if i > x:
		r += 1
	elif i < x:
		l += 1
print(min(l, r))


from bisect import bisect_left

def main():
	(N, M, X) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	mid = bisect_left(A, X)
	l = len(A[:mid])
	r = len(A[mid:])
	print(min(l, r))

def __starting_point():
	main()
__starting_point()


(N, M, X) = map(int, input().split())
A = sum((int(i) < X for i in input().split()))
print(min(A, M - A))


import numpy as np
(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a)
ans = min(len(a[a < x]), len(a[a > x]))
print(ans)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
for k in a:
	if k > x:
		i += 1
	elif k < x:
		j += 1
print(min(i, j))


(n, m, x) = map(int, input().split())
a = [int(s) for s in input().split()]
for i in range(m):
	if a[i] > x:
		less = len(a[:i])
		more = len(a[i:])
		print(min(less, more))
		break


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
goal_N = 0
goal_0 = 0
for i in range(X, N + 1):
	if i in A:
		goal_N += 1
for i in range(0, X + 1):
	if i in A:
		goal_0 += 1
min_cost = min(goal_N, goal_0)
print(min_cost)


(N, M, X) = map(int, input().split())
A = [*map(int, input().split())]
l = [i < X for i in A]
r = [i > X for i in A]
print(l.count(False) if l.count(False) < r.count(False) else r.count(False))


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

class Solution:

	def __init__(self, n, m, x, am):
		self.n = n
		self.m = m
		self.x = x
		self.am = am

	def __make_list(self):
		list_n = [0] * n
		for i in self.am:
			list_n[i - 1] = 1
		return list_n

	def answer(self):
		list_n = self.__make_list()
		print(min(sum(list_n[:self.x - 1]), sum(list_n[x - 1:])))
conditions = Solution(n, m, x, am)
conditions.answer()


(n, m, x) = map(int, input().split())
a = [int(s) for s in input().split()]
cost = []
count = 0
for i in range(x, n):
	if a.count(i) == 1:
		count += 1
cost.append(count)
count = 0
c = range(0, x)
for i in reversed(c):
	if a.count(i) == 1:
		count += 1
cost.append(count)
print(min(cost))


(n, m, x) = input().split()
list01 = input().split()
list02 = [int(a) for a in list01]
b = sum((c > int(x) for c in list02))
d = sum((e < int(x) for e in list02))
print(min(b, d))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
sum1 = 0
sum2 = 0
for i in range(M):
	if A[i] < X:
		sum1 += 1
	else:
		sum2 += 1
print(min(sum1, sum2))


import sys
(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
b = 0
for i in a:
	if i < x:
		s += 1
	if i > x:
		b += 1
print(min(s, b))


from bisect import bisect_left
(n, m, x, *a) = list(map(int, open(0).read().split()))
b = bisect_left(a, x)
print(min(m - b, b))


(n, m, x) = map(int, input().split())
lst = list(map(int, input().split()))
a_cost = 0
b_cost = 0
for i in lst:
	if i > x:
		a_cost += 1
	else:
		b_cost += 1
print(min(a_cost, b_cost))


(n, m, x) = map(int, input().split())
back = 0
for a in map(int, input().split()):
	if a < x:
		back += 1
else:
	print(min(back, m - back))


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
l_cost = 0
g_cost = 0
for i in A:
	if i > X:
		l_cost += 1
	else:
		g_cost += 1
print(min(l_cost, g_cost))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, list(input().split())))
countA = 0
countB = 0
for i in A:
	if i > X:
		countA += 1
	if i < X:
		countB += 1
if countA < countB:
	print(countA)
else:
	print(countB)


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
right = 0
left = 0
for a in A:
	if X > a:
		right += 1
	elif X < a:
		left += 1
print(min(right, left))


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
small_cost = 0
big_cost = 0
for i in a:
	if x > i:
		small_cost += 1
	elif x < i:
		big_cost += 1
if small_cost <= big_cost:
	print(small_cost)
else:
	print(big_cost)


(N, M, X) = map(int, input().split())
cost_masses = map(int, input().split())
cost_ToZero = cost_ToEnd = 0
for cost_mass in cost_masses:
	if X < cost_mass:
		cost_ToEnd = cost_ToEnd + 1
	elif X > cost_mass:
		cost_ToZero = cost_ToZero + 1
else:
	print(min([cost_ToZero, cost_ToEnd]))


(n, m, x) = map(int, input().split())
l = 0
a = list(map(int, input().split()))
for j in a:
	l += 1 if j > x else 0
print(min(l, m - l))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
A.append(X)
A.sort()
A_index = A.index(X)
len_bef = len(A[0:A_index])
len_aft = len(A[A_index + 1:])
ans = len_bef
if len_bef > len_aft:
	ans = len_aft
print(ans)


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(n, m, x) = Input()
	a = [0] * n
	for i in Input():
		a[i - 1] = 1
	print(min(sum(a[:x]), sum(a[x - 1:])))
main()


def main():
	(n, m, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for i in range(m):
		if a[i] > x:
			ans = min(i, len(a) - i)
			break
	else:
		ans = 0
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
for (i, a) in enumerate(A):
	if X < a:
		break
if i > len(A) / 2:
	ans = len(A[i:])
else:
	ans = len(A[:i])
print(ans)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
data = [0] * (n + 1)
cost_1 = 0
cost_2 = 0
for i in range(m):
	data[a[i]] = 1
for i in range(0, x):
	cost_1 += data[i]
for j in range(x, n):
	cost_2 += data[j]
print(min(cost_1, cost_2))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
square = list(range(0, N + 1))
a = square[:X + 1]
b = square[X:]
a_costs = []
b_costs = []
for i in a:
	if i in A:
		a_costs.append(i)
for i in b:
	if i in A:
		b_costs.append(i)
a_cost = len(a_costs)
b_cost = len(b_costs)
if a_cost > b_cost:
	print(b_cost)
else:
	print(a_cost)


(n, m, x) = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
print(len(a[:a.index(x)]) if len(a[:a.index(x) + 1]) <= len(a[a.index(x) + 1:]) else len(a[a.index(x) + 1:]))


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


(n, m, s) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
low = 0
high = 0
for i in range(m):
	if a[i] < s:
		low += 1
	else:
		high += 1
print(min(low, high))


(N, M, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
zero_goal = 0
N_goal = 0
for i in A:
	if i < X:
		zero_goal = zero_goal + 1
	else:
		N_goal = N_goal + 1
print(min(zero_goal, N_goal))


(n, m, x) = list(map(int, input().split()))
am = list(map(int, input().split()))
list_n = [0] * n
for i in am:
	list_n[i - 1] = 1
print(min(sum(list_n[:x - 1]), sum(list_n[x - 1:])))


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
cost_0 = 0
cost_last = 0
for n in A:
	if n > X:
		cost_last += 1
	elif n < X:
		cost_0 += 1
if cost_0 >= cost_last:
	print(cost_last)
elif cost_0 < cost_last:
	print(cost_0)


(n, m, x) = list(map(int, input().split()))
l = [0] * n
a = list(map(int, input().split()))
for i in a:
	l[i - 1] = 1
left = sum(l[:x])
right = sum(l[x - 1:len(l)])
print(left if left <= right else right)


(N, M, X) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
import bisect
idx = bisect.bisect(A, X)
ans_r = len(A[idx:])
ans_l = len(A[:idx])
ans = min(ans_l, ans_r)
print(ans)


(n, m, x) = list(map(int, input().split()))
squares = list(map(int, input().split()))
left_cost = 0
right_cost = 0
for square in squares:
	if square < x:
		left_cost = left_cost + 1
	else:
		right_cost = right_cost + 1
print(min(right_cost, left_cost))


(n, m, x) = map(int, input().split())
a_l = list(map(int, input().split()))
for (i, a) in enumerate(a_l):
	if x < a:
		break
if i > len(a_l) / 2:
	ans = len(a_l[i:])
else:
	ans = len(a_l[:i])
print(ans)


(n, m, x) = list(map(int, input().split()))
arr = list(map(int, input().split()))
mn = 0
l_cost = 0
r_cost = 0
for i in range(x):
	if i in arr:
		l_cost += 1
for i in range(x, n + 1):
	if i in arr:
		r_cost += 1
print(min(l_cost, r_cost))