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.
[{"code": "import bisect\n\nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\n\nindex = bisect.bisect_left(A,X)\nans = min(M-index,index)\nprint(ans)", "passed": true, "time": 0.88, "memory": 14120.0, "status": "done"}, {"code": "n,m,x=map(int, input().split())\na=[int(i) for i in input().split()]\n\ncount_1=0\nfor i in range(x):\n    if i in a:\n        count_1+=1\n        \ncount_2=0\nfor i in range(x,n):\n    if i in a:\n        count_2+=1\n        \nprint(min(count_1, count_2))", "passed": true, "time": 0.27, "memory": 14180.0, "status": "done"}, {"code": "# B - Toll Gates\n# https://atcoder.jp/contests/abc094/tasks/abc094_b\n\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ncost1 = 0\ncost2 = 0\n\nfor i in range(x, 0, -1):\n    if i in a:\n        cost1 += 1\n\nfor i in range(x, n):\n    if i in a:\n        cost2 += 1\n\ncost = [cost1, cost2]\nprint((min(cost)))\n", "passed": true, "time": 0.23, "memory": 14308.0, "status": "done"}, {"code": "# 094b\n\ndef atc_094b(NMX: str, Ai_input: str) -> int:\n    N, M, X = list(map(int, NMX.split(\" \")))\n    Ai = [int(ai) for ai in Ai_input.split(\" \")]\n\n    up_cost = 0\n    down_cost = 0\n\n    for i in range(X + 1, N + 1):\n        if i in Ai:\n            up_cost += 1\n    for i in range(X - 1, 0, -1):\n        if i in Ai:\n            down_cost += 1\n    return min(up_cost, down_cost)\n\n\nNMX_input_value = input()\nAi_input_value = input()\nprint((atc_094b(NMX_input_value, Ai_input_value)))\n", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\nam=sorted(map(int,input().split()))\nprint(min(len(list(filter(lambda a:a<x,am))),len(list(filter(lambda a:x<a,am)))))", "passed": true, "time": 0.24, "memory": 14168.0, "status": "done"}, {"code": "lst = input().split()\nN = int(lst[0])\nM = int(lst[1])\nX = int(lst[2])\nL = input().split()\n\ncost_0 = 0\nfor n in L:\n   if 0 < int(n) < X:\n      cost_0 += 1\n   elif X < int(n):\n      break\n\ncost_N = 0\nfor n in L:\n   if X < int(n) < N:\n      cost_N += 1\n\nprint(min([cost_0, cost_N]))", "passed": true, "time": 0.18, "memory": 14068.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\nroot0 = 0\nrootn = 0\nfor i in range(1,x):\n  if i in a:\n    root0 += 1\nfor i in range(x+1,n+1):\n  if i in a:\n    rootn += 1\nprint(min(root0,rootn))", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n    n,m,x = map(int,input().split())\n    maps=[]\n    maps=list(map(int,input().split()))\n    dp=[0]*(n+1)\n    left=0\n    right=0\n\n    for i in maps:\n        dp[i]=1\n\n    left = sum(dp[x:])\n    right = sum(dp[:x])\n\n    print(min(left,right))\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.28, "memory": 14096.0, "status": "done"}, {"code": "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nn, m, x = [int(num) for num in lines.pop(0).split(\" \")]\na_list = [int(num) for num in lines.pop(0).split(\" \")]\n\nfor i in range(m):\n    if a_list[i] > x:\n        break\n\nans = min(i, m - i)\nprint(ans)\n", "passed": true, "time": 0.22, "memory": 14168.0, "status": "done"}, {"code": "total_square, total_toll_gate, current_square = map(int, input().split())\ntoll_gate_square = list(map(int, input().split()))\nroute1 = 0\nroute2 = 0\nfor i in range(total_toll_gate):\n    if toll_gate_square[i] < current_square:\n        route1 += 1\n    else:\n        route2 += 1\nprint(min(route1, route2))", "passed": true, "time": 0.27, "memory": 14304.0, "status": "done"}, {"code": "# B - Toll Gates\n\n# N M X\nN, M, X = list(map(int, input().split()))\nmy_list = list(map(int, input().split(maxsplit=M)))\ncount_start = 0\ncount_goal = 0\n\n# 0\u3078\u884c\u304f\u30d1\u30bf\u30fc\u30f3\nfor i in range(1, X):\n    if i in my_list:\n        count_start += 1\n\nfor i in range(X, N):\n    if i in my_list:\n        count_goal += 1\n\nif count_start >= count_goal:\n    answer = count_goal\nelse:\n    answer = count_start\n\nprint(answer)\n", "passed": true, "time": 0.2, "memory": 14288.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\nA=list(map(int,input().split()))\nprint(min(sum([a<x for a in A]),sum([a>x for a in A])))", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na=list(map(int,input().split()))\ncnt1, cnt2 = 0, 0\nfor i in range(m):\n  if 0 <= a[i] < x:\n    cnt1 += 1\n  if x < a[i] <= a[-1]:\n    cnt2 += 1\nprint(min(cnt1, cnt2))", "passed": true, "time": 0.14, "memory": 14356.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nX_high = 0\nX_low = 0\n\nfor i in range(X, N + 1):\n    if i in A:\n        X_high += 1\n\nfor i in range(0, X + 1):\n    if i in A:\n        X_low += 1\n\nprint(min(X_high, X_low))", "passed": true, "time": 0.18, "memory": 14328.0, "status": "done"}, {"code": "N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(X,0,-1):\n    if i in Ai:\n        goto_0 += 1\n\nfor i in range(X,N):\n    if i in Ai:\n        goto_N += 1\n\nprint(min(goto_0,goto_N))", "passed": true, "time": 0.14, "memory": 14360.0, "status": "done"}, {"code": "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n    if X > i:\n        l1.append(i)\n    else:\n        l2.append(i)\n\nprint((min(len(l1), len(l2))))\n", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "def tool_gate(now: int, gate_list: list) -> int:\n    back_count = sum(i < now for i in gate_list)\n    forward_count = sum(i > now for i in gate_list)\n    return min(back_count, forward_count)\n\n\ndef __starting_point():\n    n, m, now = list(map(int, input().split()))\n    gate_list = list(map(int, input().split()))\n    print((tool_gate(now, gate_list)))\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na =list(map(int,input().split()))\nstart = sum(i>x for i in a)\nend = sum(i<x for i in a)\nprint(min(start,end))", "passed": true, "time": 0.14, "memory": 14348.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n \nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\nif A[int(M/2)] > X:\n  b = [i for i in A if i < X]\nelse:\n  for i in A[::-1]:\n     b = [i for i in A if i > X]\n  \nprint(min(len(b),M - len(b)))", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "# \u6570\u5024\u306e\u53d6\u5f97\nlast,fee,cur = map(int,input().split())\nfeesqu = list(map(int,input().split()))\ntotal = len(feesqu)\n\n# \u30b3\u30b9\u30c8\u306e\u6700\u5c0f\u5024\u3092\u51fa\u529b\ntcost = 0\ngcost = 0\nfor cnt in range(0,total,1):\n    if feesqu[cnt] < cur:\n        tcost += 1\ngcost = total - tcost\nprint(min(tcost,gcost))", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "N, M, X = list(map(int, input().split()))\na_point = list(map(int,input().split()))\nlg = 0\nsl = 0\nfor i in range(len(a_point)):\n    if X < a_point[i]:\n        lg  += 1\n    else:\n        sl += 1\n\nif lg > sl:\n    print(sl)\nelse:\n    print(lg)\n", "passed": true, "time": 0.14, "memory": 14336.0, "status": "done"}, {"code": "N, M, X = map(int,input().split())\nfee = list(map(int,input().split()))\nresult_1 = []\nresult_2 = []\n\nfor i in fee:\n    if i > X:\n        result_1.append(i)\n    else:\n        result_2.append(i)\n\nresult = (min(len(result_1) ,len(result_2)))\nprint(result)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nans=0\nfor i in a:\n    if i<x:\n        ans+=1\n    else:\n        break\nprint(min(ans,m-ans))", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\na_lst = list(map(int, input().split()))\n\ncost1 = 0\ncost2 = 0\nfor i in range(x, n+1):\n  if i in a_lst:\n    cost1 += 1\nfor i in range(x, -1, -1):\n  if i in a_lst:\n    cost2 += 1\nprint((min(cost1, cost2)))\n", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "import bisect\n\n\ndef answer(n: int, m: int, x: int, a: []) -> int:\n    i = bisect.bisect_left(a, x)\n    return min(i, len(a) - i)\n\n\ndef main():\n    n, m, x = map(int, input().split())\n    a = list(map(int, input().split()))\n    print(answer(n, m, x, a))\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "N, M, X = [int(i) for i in input().split()]\nAS = [int(i) for i in input().split()]\n\ncnt1 = 0\nfor i in range(0, X):\n  if i in AS:\n    cnt1 += 1\n\ncnt2 = 0\nfor i in range(X+1, N+1):\n  if i in AS:\n    cnt2 += 1\n\nprint((cnt1 if cnt1 < cnt2 else cnt2))\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "# \u5165\u529b\nn, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1):   # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n    if i in a:\n        goto_goal_0 += 1\n        # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1):   # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n    if i in a:\n        goto_goal_n += 1\n        # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n    print(goto_goal_0)\nelse:\n    print(goto_goal_n)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "N, M, X = map(int,input().split())\nA = map(int,input().split())\n\nL = 0\nR = 0\n\nfor ai in A:\n    if ai < X:\n        L = L + 1\n    else:\n        R = R + 1\nprint(min(L, R))", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n \nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\ncount = 0\nif A[int(M/2)] > X:\n  for i in A:\n    if i < X:\n      count += 1\n    else:\n      break\nelse:\n  for i in A[::-1]:\n    if i > X:\n      count += 1\n    else:\n      break\n  \nprint((min(count,M - count)))\n", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nright = [int(i) for i in A if i > X]\nleft = [int(i) for i in A if i < X]\n\nr = len(right)\nl = len(left)\n\nif r < l:\n    print(r)\n\nelse:\n    print(l)", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "a = [int(c) for c in input().split()]\nN=a[0]\nM=a[1]\nX=a[2]\nA = [int(c) for c in input().split()]\nA2 = [0]*(N+1)\nfor i in range(M):\n    A2[A[i]] = 1\n\ncnt = X\ncost1 = 0\nwhile cnt < N+1:\n    cost1+=A2[cnt]\n    cnt+=1\n\ncnt = X\ncost2 = 0\nwhile cnt > 0:\n    cost2+=A2[cnt]\n    cnt-=1\n\nif cost1<cost2:\n    print(cost1)\nelse:\n    print(cost2)\n", "passed": true, "time": 0.14, "memory": 14164.0, "status": "done"}, {"code": "a=input().split()\nN=int(a[0])\nM=int(a[1])\nX=int(a[2])\nryokinjo=[]\nb=input().split()\nfor i in range(len(b)):\n  ryokinjo.append(int(b[i]))\ncount1=0\ncount2=0\nfor i in range(len(ryokinjo)):\n  if ryokinjo[i]<X:\n    count1+=1\n  if ryokinjo[i]>X:\n    count2+=1\nprint((min([count1,count2])))\n", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=list(map(int,input().split()))\ne=0\nf=0\nfor i in range(b):\n  if d[i]>c:\n    e=e+1\n  if d[i]<c:\n    f=f+1\nif e>f:\n  print(f)\nelse:\n  print(e)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "N,M,X=map(int,input().split())\nA=list(map(int,input().split()))\ncnt=len([a for a,i in enumerate(A) if i>=X])\ncnt=min(cnt,M-cnt)\nprint(cnt)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\ncnt1 = 0\ncnt2 = 0\nx1 = x\nx2 = x\n\nwhile x1 < n+1:\n    x1 += 1\n    if x1 in a:\n        cnt1 += 1\n\nwhile x2 > 0:\n    x2 -= 1\n    if x2 in a:\n        cnt2 += 1\n\n\n\nif cnt1 < cnt2:\n    ans = cnt1\nelse:\n    ans = cnt2\n\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14332.0, "status": "done"}, {"code": "N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(0,X):\n    if i in Ai:\n        goto_0 += 1\n\nfor i in range(X,N):\n    if i in Ai:\n        goto_N += 1\n\nprint(min(goto_0,goto_N))", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\nacc = [0] * (n + 1)\nfor i in a:\n    acc[i] = 1\nprint(min(sum(acc[:x]), sum(acc[x:])))", "passed": true, "time": 0.26, "memory": 14104.0, "status": "done"}, {"code": "num, count_station, my_position = list(map(int, input().split()))\na = list(map(int, input().split()))\nstation_list = list(a)\nspace = num + 1\nfirst_me_cost = 0\nlast_me_cost = 0\n\ndistance_me_first = my_position\ndistance_me_last = num - my_position\n\nfor i in station_list:\n    if 1 <= i <= my_position - 1:\n        first_me_cost += 1\n\nfor i in station_list:\n    if my_position + 1 <= i < num:\n        last_me_cost += 1\n\nif first_me_cost > last_me_cost:\n    print(last_me_cost)\nelif last_me_cost > first_me_cost:\n    print(first_me_cost)\nelif last_me_cost == first_me_cost:\n    print(first_me_cost)\n", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nc=x\nans=0\nans1=0\nwhile c:\n  ans+=c in a\n  c-=1\nwhile x<n:\n  ans1+=x in a\n  x+=1\nprint(min(ans,ans1))", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = sorted(A)\nC = [0]*(N+1)\ncnt_1 = 0\ncnt_2 = 0\n\nfor i in range(M):\n    C[B[i]] += 1\n\nfor j in range(1, N-X):\n    cnt_1 += C[X+j]\n\nfor k in range(1, X+1):\n    cnt_2 += C[X-k]\n\ncnt = [cnt_1, cnt_2]\n\nprint((min(cnt)))\n", "passed": true, "time": 0.15, "memory": 14144.0, "status": "done"}, {"code": "n,m,x = list(map(int,input().split()))\na = list(map(int,input().split()))\nk = n-1\nfor i in range(m):\n    if a[i] > x:\n        k = i\n        break\nif k==0 or k==n-1:\n    print('0')\n    return\nelse:\n    print((min(k,m-k)))\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "S_list = [input() for i in range(2)]\nN, M, X= map(int,S_list[0].split())    \nA_list = list(map(int,S_list[1].split()))\n\nA_goal_N = [i for i in A_list if X < i and i < N]\nA_goal_0 = [i for i in A_list if 0 < i and i < X]\nresult = min(len(A_goal_N),len(A_goal_0))\nprint(result)", "passed": true, "time": 0.15, "memory": 14344.0, "status": "done"}, {"code": "n, m, x = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ngoal_0 = 0\ngoal_1 = 0\n\nfor i in range(x,0,-1):\n    if i in a:\n        goal_0 += 1\n\nfor i in range(x,n+1,1):\n    if i in a:\n        goal_1 += 1\n\nif goal_0 < goal_1:\n    print(goal_0)\nelse:\n    print(goal_1)\n", "passed": true, "time": 0.15, "memory": 14360.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\na=list(map(int, input().split()))\np = 0\nq = 0\nfor i in a:\n    if i > x:\n        p +=1\n    elif i < x:\n        q +=1\nprint(min(p,q))", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}, {"code": "#ABC094 B 3\u756a\u76ee\u304c\u901a\u3089\u306a\u3044\nn,m,x=map(int,input().split())\nList=[int(i) for i in input().split()]\nlcost=0\nrcost=0\nfor a in List:\n    if a<x:\n        lcost+=1\n\nfor b in List:\n    if b>x:\n        rcost+=1\nprint(min(lcost,rcost))", "passed": true, "time": 0.22, "memory": 14064.0, "status": "done"}, {"code": "n,m,x = list(map(int, input().split()))\na = list(map(int, input().split()))\nc0 = 0\ncN = 0\nfor A in a:\n    if A > x:\n        cN += 1\n    elif A < x:\n        c0 += 1\nprint(min(c0, cN))", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "# 094b\n\ndef atc_094b(NMX: str, Ai_input: str) -> int:\n    N, M, X = list(map(int, NMX.split(\" \")))\n    Ai = [int(ai) for ai in Ai_input.split(\" \")]\n\n    up_cost = 0\n    down_cost = 0\n\n    for i in range(X + 1, N + 1):\n        if i in Ai:\n            up_cost += 1\n    for i in range(X - 1, 0, -1):\n        if i in Ai:\n            down_cost += 1\n    return min(up_cost, down_cost)\n\n\nNMX_input_value = input()\nAi_input_value = input()\nprint((atc_094b(NMX_input_value, Ai_input_value)))\n", "passed": true, "time": 0.22, "memory": 14188.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\ndef answer(n: int, m: int, x: int, a:list) -> int:\n    left = 0\n    right = 0\n    for i in a:\n        if i < x:\n            left += 1\n        else:\n            right += 1\n    return min(left, right)\n\nprint(answer(n, m, x, a))", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "N, M, X = map(int,input().split())\nL = list(map(int,input().split()))\ns = 0\nb = 0\nfor i in L:\n    if i > X:\n        s += 1\n    else:\n        b += 1\n\nif s >= b:\n    print(b)\nelse:\n    print(s)", "passed": true, "time": 0.15, "memory": 14184.0, "status": "done"}, {"code": "N, M, X = list(map(int,input().split()))\nS = list(map(int,input().split()))\nFees = list(S)\nGoal1 = []\nGoal2 = []\ncount1 = 0\ncount2 = 0\npoint0 = 0\n\nfor i in range(X):\n    point0 += 1\n    Goal1.append(point0)\n# print(Goal1)\n\nfor j in range(N-X):\n    X += 1\n    Goal2.append(X)\n# print(Goal2)\n\nfor fee in Fees:\n    if fee in Goal1:\n        count1 += 1\n    if fee in Goal2:\n        count2 += 1\n\nif count1 >= count2:\n    print(count2)\nif count1 < count2:\n    print(count1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Fee = list(S)\n# print(Fee)\n# count1 = 0\n# count2 = 0\n# for i in range(N-X):\n#     X += 1\n#     if X in Fee:\n#         count1 += 1\n# print(X)\n# for j in range(N):\n#     X -= 1\n#     if X in Fee:\n#         count2 += 1\n#\n# if count1 <= count2:\n#     print(count1)\n# if count1 > count2:\n#     print(count2)\n", "passed": true, "time": 0.23, "memory": 14236.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nl = 0\n\nfor i in a:\n    if i > x:\n        r += 1\n    elif i < x:\n        l += 1\n\nprint(min(l,r))", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "from bisect import bisect_left\n\ndef main():\n    N, M, X = list(map(int, input().split()))\n    A = list(map(int, input().split()))\n    mid = bisect_left(A, X)\n    l = len(A[:mid])\n    r = len(A[mid:])\n    print((min(l, r)))\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nfor i in range(x+1,n):\n    for j in range(m):\n        if i == a[j]:\n            r += 1\n\nl = 0\nfor i in range(x-1, -1, -1):\n    for j in range(m):\n        if i == a[j]:\n            l += 1\n        \nprint(min(l,r))", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "\n# \u5165\u529b\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1):   # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n    if i in a:\n        goto_goal_0 += 1\n        # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1):   # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n    if i in a:\n        goto_goal_n += 1\n        # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n    print(goto_goal_0)\nelse:\n    print(goto_goal_n)\n", "passed": true, "time": 0.23, "memory": 14384.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = sum(int(i) < X for i in input().split())\nprint(min(A, M - A))", "passed": true, "time": 1.04, "memory": 14092.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ni = 0\nj = 0\nfor k in a:\n    if k>x:\n        i += 1\n    elif k<x:\n        j += 1\nprint(min(i,j))", "passed": true, "time": 0.93, "memory": 14104.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\na = [int(s) for s in input().split()]\n\nfor i in range(m):\n    if a[i] > x:\n        less = len(a[:i])\n        more = len(a[i:])\n        print(min(less, more))\n        break", "passed": true, "time": 0.19, "memory": 14380.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n    if i in A:\n        goal_N += 1\n\nfor i in range(0, X + 1):\n    if i in A:\n        goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)", "passed": true, "time": 0.16, "memory": 14148.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = [*map(int, input().split())]\nl = [i < X for i in A]\nr = [i > X for i in A]\nprint(l.count(False) if l.count(False) < r.count(False) else r.count(False))", "passed": true, "time": 0.14, "memory": 14020.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\n\n\nclass Solution:\n    def __init__(self, n, m, x, am):\n        self.n = n\n        self.m = m\n        self.x = x\n        self.am = am\n\n    def __make_list(self):\n        list_n = [0] * n\n        for i in self.am:\n            list_n[i - 1] = 1\n        return list_n\n\n    def answer(self):\n        list_n = self.__make_list()\n        print((min(sum(list_n[:self.x - 1]), sum(list_n[x - 1:]))))\n\n\nconditions = Solution(n, m, x, am)\nconditions.answer()\n", "passed": true, "time": 0.16, "memory": 14036.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = [int(s) for s in input().split()]\ncost = []\ncount = 0\n\nfor i in range(x,n):\n    if a.count(i) == 1:\n        count += 1\ncost.append(count)\ncount = 0\nc = range(0,x)\nfor i in reversed(c):\n    if a.count(i) == 1:\n        count += 1\ncost.append(count)\nprint(min(cost))", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "n,m,x=map(int, input().split())\na=list(map(int, input().split()))\nmas=[0]*(n+1)\nfor i in a:\n    mas[i]=1\nprint(min(sum(mas[0:x]),sum(mas[x:n+1])))", "passed": true, "time": 0.22, "memory": 14196.0, "status": "done"}, {"code": "n, m, x = input().split()\nlist01 = input().split()\nlist02 = [int(a) for a in list01]\nb = sum(c > int(x) for c in list02)\nd = sum(e < int(x) for e in list02)\nprint(min(b, d))", "passed": true, "time": 0.27, "memory": 14068.0, "status": "done"}, {"code": "N,M,X=list(map(int,input().split()))\nA=list(map(int,input().split()))\nsum1=0\nsum2=0\nfor i in range(M):\n    if A[i]<X:\n        sum1+=1\n    else:\n        sum2+=1\nprint((min(sum1,sum2)))\n", "passed": true, "time": 0.15, "memory": 14284.0, "status": "done"}, {"code": "import sys\nn,m,x=map(int,input().split())\na=list(map(int,input().split()))\n\ns=0\nb=0\nfor i in a:\n    if i<x:\n        s+=1\n    if i>x:\n        b+=1\nprint(min(s,b))", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\nlst = list(map(int, input().split()))\n\na_cost = 0\nb_cost = 0\nfor i in lst:\n    if i > x:\n        a_cost += 1\n    else:\n        b_cost += 1\nprint(min(a_cost, b_cost))", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "N, M, X = map(int,input().split())\nA = list(map(int,input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n    if i in A:\n        goal_N += 1\n\nfor i in range(0, X + 1):\n    if i in A:\n        goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n    if a < x:\n        back += 1\nelse:\n    print(min(back, m - back))", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nl_cost = 0\ng_cost = 0\n\nfor i in A:\n    if i > X:\n      l_cost += 1\n    else:\n        g_cost += 1\n        \nprint(min(l_cost, g_cost))", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "_, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n    if a < x:\n        back += 1\nelse:\n    print(min(back, m - back))", "passed": true, "time": 0.15, "memory": 14068.0, "status": "done"}, {"code": "N,M,X=list(map(int,input().split()))\nA=list(map(int,list(input().split())))\ncountA=0\ncountB=0\nfor i in A:\n    if i>X:\n        countA+=1\n    if i<X:\n        countB+=1\nif countA<countB:\n    print(countA)\nelse:\n    print(countB)\n", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nright = 0\nleft = 0\n\nfor a in A:\n    if X > a:\n        right += 1\n    elif X < a:\n        left += 1\n\nprint((min(right, left)))\n\n\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\n\n# \u5c0f\u3055\u3044\u307b\u3046\u306e\u6599\u91d1\u6240\u306e\u6570\nsmall_cost = 0\n# \u5927\u304d\u3044\u65b9\u306e\u6599\u91d1\u6240\u306e\u6570\nbig_cost = 0\n\n# \u30ea\u30b9\u30c8a\u306e\u5024\u3068\uff58\u3092\u6bd4\u8f03\u3057\u3066\nfor i in a:\n    # \uff58\u3088\u308a\u5c0f\u3055\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n    if x > i:\n        small_cost += 1\n    # \uff58\u3088\u308a\u5927\u304d\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n    elif x < i:\n        big_cost += 1\n# \u5c11\u306a\u3044\u65b9\u306e\u30ab\u30a6\u30f3\u30c8\u3092\u51fa\u529b\nif small_cost <= big_cost:\n    print(small_cost)\nelse:\n    print(big_cost)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\ncost_masses = map(int, input().split())\n\ncost_ToZero = cost_ToEnd = 0\n\nfor cost_mass in cost_masses:\n    if X < cost_mass:\n        cost_ToEnd = cost_ToEnd + 1\n    elif X > cost_mass:\n        cost_ToZero = cost_ToZero + 1\nelse:\n  print(min([cost_ToZero, cost_ToEnd]))", "passed": true, "time": 0.14, "memory": 14036.0, "status": "done"}, {"code": "n, m, x = map(int,input().split())\nl = 0\na = list(map(int,input().split()))\nfor j in a:\n    l += 1 if j > x else 0\nprint(min(l,m-l))", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "# -*- coding:utf-8 -*-\nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\nA.append(X)\nA.sort()\n\nA_index = A.index(X)\n\nlen_bef = len(A[0:A_index])\nlen_aft = len(A[A_index+1:])\nans = len_bef\n\nif len_bef > len_aft:\n    ans = len_aft\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n    if X > i:\n        l1.append(i)\n    else:\n        l2.append(i)\n\nprint(min(len(l1), len(l2)))", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "def mapt(fn, *args):\n    return tuple(map(fn, *args))\n\n\ndef Input():\n    return mapt(int, input().split(\" \"))\n\n\ndef main():\n    n, m, x = Input()\n    a = [0] * n\n    for i in Input():\n        a[i-1] = 1\n\n    print(min(sum(a[:x]), sum(a[x-1:])))\n\n\nmain()", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\nans = 0\n\nfor i in range(m):\n    if a[i] > x:\n        if i < m-i: ans = i\n        else      : ans = m-i\n        break\nprint(ans)", "passed": true, "time": 0.35, "memory": 14280.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n\ndef main():\n    n, m, x = list(map(int, input().split()))\n    a = list(map(int, input().split()))\n    for i in range(m):\n        if a[i] > x:\n            ans = min(i, len(a) - i)\n            break\n    else:\n        ans = 0\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.35, "memory": 14072.0, "status": "done"}, {"code": "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nfor i , a in enumerate(A):\n    if X < a:\n        break\n\nif i > len(A) / 2:\n    ans = len(A[i:])\nelse:\n    ans = len(A[:i])\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ndata = [0]*(n + 1)\ncost_1 = 0\ncost_2 = 0\nfor i in range(m):\n    data[a[i]] = 1\nfor i in range(0,x):\n    cost_1 += data[i]\nfor j in range(x,n):\n    cost_2 += data[j]\nprint(min(cost_1,cost_2))", "passed": true, "time": 0.25, "memory": 14240.0, "status": "done"}, {"code": "# \u5168\u4f53\u306e\u30de\u30b9\u3092\u958b\u59cb\u4f4d\u7f6e\u3067\u30b9\u30e9\u30a4\u30b9\u3001\u6599\u91d1\u6240\u3060\u3051\u62bd\u51fa\u3057\u3001\u8981\u7d20\u306e\u500b\u6570\u3067\u6761\u4ef6\u5206\u5c90\nN, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nsquare = list(range(0, N + 1))\n\na = square[:X + 1]\nb = square[X:]\n\na_costs = []\nb_costs = []\n\nfor i in a:\n    if i in A:\n        a_costs.append(i)\nfor i in b:\n    if i in A:\n        b_costs.append(i)\n\na_cost = len(a_costs)\nb_cost = len(b_costs)\n\nif a_cost > b_cost:\n    print(b_cost)\nelse:\n    print(a_cost)\n", "passed": true, "time": 0.65, "memory": 14172.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\na.append(x)\na = sorted(a)\nprint(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:]))", "passed": true, "time": 0.65, "memory": 14128.0, "status": "done"}, {"code": "n,m,x = map(int,input().split())\nli = list(map(int,input().split()))\ncnt = 0\ncou = 0\nfor i in range(x):\n    if i in li:\n        cnt += 1\nfor i in range(x,n):\n    if i in li:\n        cou += 1\nprint(min(cnt,cou))", "passed": true, "time": 0.32, "memory": 14092.0, "status": "done"}, {"code": "n,m,s = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nlow = 0\nhigh = 0\nfor i in range(m):\n  if a[i] < s:\n    low += 1\n  else:\n    high += 1\nprint(min(low,high))", "passed": true, "time": 0.24, "memory": 14100.0, "status": "done"}, {"code": "N, M, X = list(map(int,input().split()))\nA = list(map(int, input().split())) \n\nzero_goal = 0\nN_goal = 0\n\nfor i in A:\n    if i < X:\n        zero_goal = zero_goal + 1\n    else:\n        N_goal = N_goal + 1\nprint((min(zero_goal, N_goal)))\n", "passed": true, "time": 0.25, "memory": 14216.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\nlist_n = [0] * n\nfor i in am:\n    list_n[i - 1] = 1\nprint((min(sum(list_n[:x - 1]), sum(list_n[x - 1:]))))\n", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\na = list(map(int, input(). split()))\n\ngoto_goal_0 = 0\ngoto_goal_n = 0\n\nfor i in range(x, 0, -1):\n    if i in a:\n        goto_goal_0 += 1\n\n\nfor i in range(x, n + 1, 1):\n    if i in a:\n        goto_goal_n += 1\n\nif goto_goal_0 < goto_goal_n:\n    print(goto_goal_0)\nelse:\n    print(goto_goal_n)\n\n", "passed": true, "time": 0.14, "memory": 14388.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ncost_0 = 0\ncost_last = 0\n\nfor n in A:\n  if n > X:\n    cost_last += 1\n  elif n < X:\n    cost_0 += 1\n\n\nif cost_0 >= cost_last:\n  print(cost_last)\nelif cost_0 < cost_last:\n  print(cost_0)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,m,x = list(map(int,input().split()))\nl = [0]*n\na = list(map(int,input().split()))\nfor i in a:\n    l[i-1] = 1\n\nleft = sum(l[:x])\nright = sum(l[x-1:len(l)])\n\nprint((left if left<=right else right))\n", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "n,m,x = list(map(int,input().split()))\na = list(map(int,input().split()))\nans = 0\nans = min(sum(1 for i in a if i > x),sum(1 for i in a if i < x))\nprint(ans)\n\n\n", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort()\n\nimport bisect\nidx = bisect.bisect(A, X)\n\nans_r = len(A[idx:])\nans_l = len(A[:idx])\n\nans = min(ans_l, ans_r)\nprint(ans)", "passed": true, "time": 0.21, "memory": 14300.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\nsquares = list(map(int, input().split()))\n\nleft_cost = 0\nright_cost = 0\nfor square in squares:\n    if square < x:\n        left_cost = left_cost + 1\n    else:\n        right_cost = right_cost + 1\n\nprint((min(right_cost, left_cost)))\n", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "n, m, x = map(int, input().split())\na_l = list(map(int, input().split()))\n\nfor i, a in enumerate(a_l):\n    if x < a:\n        break\nif i > len(a_l)/2:\n    ans = len(a_l[i:])\nelse:\n    ans = len(a_l[:i])\nprint(ans)", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "n, m, x = list(map(int, input().split()))\narr = list(map(int, input().split()))\n\nmn = 0\nl_cost = 0\nr_cost = 0\n\n# Calculate left cost\nfor i in range(x):\n    if i in arr:\n        l_cost += 1\n\n# Calculate right cost\nfor i in range(x, n + 1):\n    if i in arr:\n        r_cost += 1\n\nprint((min(l_cost, r_cost)))\n", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nk=[0]*(n+1)\nfor i in a:k[i]=1\nprint(min(sum(k[0:x+1]),sum(k[x:n+1])))", "passed": true, "time": 0.19, "memory": 14076.0, "status": "done"}]