import java.util.Arrays;
import java.util.Scanner;

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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner 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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	}
} 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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	} main {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	} 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 Integer fee[] = new Integer[m]; fee new Integer[m] m int costRight = 0; costRight 0 int costLeft =0; costLeft 0 for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		} int i = 0; int i = 0; i 0 i < m i m i ++ i ++ i {
			fee[i] =sc.nextInt();
		} {
			fee[i] =sc.nextInt();
		} fee[i] =sc.nextInt() fee[i] fee i sc.nextInt() sc.nextInt sc for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		} int i = x + 1; int i = x + 1; i x + 1 x 1 i <= n i n i ++ i ++ i {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		} {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		} if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			} Arrays.asList(fee).contains(i) Arrays.asList(fee).contains Arrays.asList(fee) Arrays.asList Arrays fee i {
				costRight ++;
			} costRight ++ costRight for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		} int i = x - 1; int i = x - 1; i x - 1 x 1 i >= 0 i 0 i -- i -- i {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		} {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		} if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			} Arrays.asList(fee).contains(i) Arrays.asList(fee).contains Arrays.asList(fee) Arrays.asList Arrays fee i {
				costLeft ++;
			} costLeft ++ costLeft if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		} costRight > costLeft costRight costLeft {
			System.out.println(costLeft);
		} System.out.println(costLeft) System.out.println System.out System System.out costLeft {
			System.out.println(costRight);
		} System.out.println(costRight) System.out.println System.out System System.out costRight 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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	}
} 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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

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();
		Integer fee[] = new Integer[m];
		int costRight = 0;
		int costLeft =0;
		
		for(int i = 0; i < m; i ++) {
			fee[i] =sc.nextInt();
		}
		
		for(int i = x + 1; i <= n; i ++) {
			if(Arrays.asList(fee).contains(i)) {
				costRight ++;
			}
		}
		
		for(int i = x - 1; i >= 0; i --) {
			if(Arrays.asList(fee).contains(i)) {
				costLeft ++;
			}
		}
		
		if(costRight > costLeft) {
			System.out.println(costLeft);
		}else {
			System.out.println(costRight);
		}
	}
}