import java.util.*;
import java.io.*;

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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	}
} import java.util.*; util.* java import java.io.*; io.* 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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	}
} 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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	} 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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	} 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 val = sc.nextInt();
			arr[val]++;
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			int val = sc.nextInt();
			arr[val]++;
		} {
			int val = sc.nextInt();
			arr[val]++;
		} int val = sc.nextInt(); val sc.nextInt() sc.nextInt sc arr[val]++ arr[val] arr val int minCost = n+1; minCost n+1 n 1 int cost = 0; cost 0 for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		} int i=x+1; int i=x+1; i x+1 x 1 i<n i n i++ i++ i {
			if(arr[i] > 0){
				cost++;
			}
		} {
			if(arr[i] > 0){
				cost++;
			}
		} if(arr[i] > 0){
				cost++;
			} arr[i] > 0 arr[i] arr i 0 {
				cost++;
			} cost++ cost if(minCost > cost){
			minCost = cost;
		} minCost > cost minCost cost {
			minCost = cost;
		} minCost = cost minCost cost cost = 0 cost 0 for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		} int i=x-1; int i=x-1; i x-1 x 1 i>0 i 0 i-- i-- i {
			if(arr[i] > 0){
				cost++;
			}
		} {
			if(arr[i] > 0){
				cost++;
			}
		} if(arr[i] > 0){
				cost++;
			} arr[i] > 0 arr[i] arr i 0 {
				cost++;
			} cost++ cost if(minCost > cost){
			minCost = cost;
		} minCost > cost minCost cost {
			minCost = cost;
		} minCost = cost minCost cost System.out.println(minCost) System.out.println System.out System System.out minCost 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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	}
} 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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	}
} Main
import java.util.*;
import java.io.*;

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 val = sc.nextInt();
			arr[val]++;
		}
		
		int minCost = n+1;
		int cost = 0;

		for(int i=x+1; i<n; i++){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}

		cost = 0;

		for(int i=x-1; i>0; i--){
			if(arr[i] > 0){
				cost++;
			}
		}

		if(minCost > cost){
			minCost = cost;
		}	

		System.out.println(minCost);
	}
}
