output_description: Print the minimum cost incurred before reaching the goal.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M X
      A_1 A_2 ... A_M
attempt: import sys, re
  from collections import deque, defaultdict, Counter
  from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
  from itertools import accumulate, permutations, combinations, product, groupby
  from operator import itemgetter, mul
  from copy import deepcopy
  from string import ascii_lowercase, ascii_uppercase, digits
  from bisect import bisect, bisect_left
  from fractions import gcd
  from heapq import heappush, heappop
  from functools import reduce
  
  
  def input():
      return sys.stdin.readline().strip()
  
  
  def INT():
      return int(input())
  
  
  def MAP():
      return map(int, input().split())
  
  
  def LIST():
      return list(map(int, input().split()))
  
  
  def ZIP(n):
      return zip(*(MAP() for _ in range(n)))
  
  
  sys.setrecursionlimit(10**9)
  INF = float("inf")
  mod = 10**9 + 7
  
  N, M, X = MAP()
  A = LIST()
  
  cost = [0] * (N + 1)
  
  for i in range(M):
      cost[A[i]] = 1
  
  print(min(sum(cost[:X]), sum(cost[X:])))
  
problem_description: Statement
  
  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.
samples: [{"input": "5 3 3\n    1 2 4", "output": "1\n    \n\nThe optimal solution is as follows:\n\n  * First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.\n  * Then, travel from Square 4 to Square 5. This time, no cost is incurred.\n  * Now, we are in Square 5 and we have reached the goal.\n\nIn this case, the total cost incurred is 1.\n\n* * *"}, {"input": "7 3 2\n    4 5 6", "output": "0\n    \n\nWe may be able to reach the goal at no cost.\n\n* * *"}, {"input": "10 7 5\n    1 2 3 4 6 8 9", "output": "3"}]