import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int[] arr = new int[N+1]; arr new int[N+1] N+1 N 1 for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    } int i = 0; int i = 0; i 0 i<M i M i++ i++ i {
        int idx = sc.nextInt();
        arr[idx] = 1;
    } {
        int idx = sc.nextInt();
        arr[idx] = 1;
    } int idx = sc.nextInt(); idx sc.nextInt() sc.nextInt sc arr[idx] = 1 arr[idx] arr idx 1 for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    } int i = X+1; int i = X+1; i X+1 X 1 i<N i N i++ i++ i {
      arr[i+1] += arr[i];
    } {
      arr[i+1] += arr[i];
    } arr[i+1] += arr[i] arr[i+1] arr i+1 i 1 arr[i] arr i for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    } int i = X-1; int i = X-1; i X-1 X 1 i>0 i 0 i-- i-- i {
      arr[i-1] += arr[i];
    } {
      arr[i-1] += arr[i];
    } arr[i-1] += arr[i] arr[i-1] arr i-1 i 1 arr[i] arr i int res = Math.min(arr[0],arr[N]); res Math.min(arr[0],arr[N]) Math.min Math arr[0] arr 0 arr[N] arr N System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] arr = new int[N+1];
    for(int i = 0; i<M; i++){
        int idx = sc.nextInt();
        arr[idx] = 1;
    }
    for(int i = X+1; i<N; i++){
      arr[i+1] += arr[i];
    }
    for(int i = X-1; i>0; i--){
      arr[i-1] += arr[i];
    }
    int res = Math.min(arr[0],arr[N]);
    System.out.println(res);
  }
}