import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List 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 GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	} main {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int GoukeiMasu = sc.nextInt() + 1; GoukeiMasu sc.nextInt() + 1 sc.nextInt() sc.nextInt sc 1 int ryokinjyoSuu = sc.nextInt(); ryokinjyoSuu sc.nextInt() sc.nextInt sc int syokaiIti = sc.nextInt(); syokaiIti sc.nextInt() sc.nextInt sc List<Integer> ryokinjyoItiList = new ArrayList<Integer>(); ryokinjyoItiList new ArrayList<Integer>() for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		} int i=0; int i=0; i 0 i<ryokinjyoSuu i ryokinjyoSuu i++ i++ i {
			ryokinjyoItiList.add(sc.nextInt());
		} {
			ryokinjyoItiList.add(sc.nextInt());
		} ryokinjyoItiList.add(sc.nextInt()) ryokinjyoItiList.add ryokinjyoItiList sc.nextInt() sc.nextInt sc int imanoIti = syokaiIti; imanoIti syokaiIti int hidariRyokin = 0; hidariRyokin 0 while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		} imanoIti != 0 imanoIti 0 {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		} imanoIti-- imanoIti if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			} ryokinjyoItiList.contains(imanoIti) ryokinjyoItiList.contains ryokinjyoItiList imanoIti {
				hidariRyokin++;
			} hidariRyokin++ hidariRyokin imanoIti = syokaiIti imanoIti syokaiIti int migiRyokin = 0; migiRyokin 0 while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		} GoukeiMasu != imanoIti GoukeiMasu imanoIti {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		} imanoIti++ imanoIti if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			} ryokinjyoItiList.contains(imanoIti) ryokinjyoItiList.contains ryokinjyoItiList imanoIti {
				migiRyokin++;
			} migiRyokin++ migiRyokin System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin) System.out.println System.out System System.out (hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin (hidariRyokin<migiRyokin) hidariRyokin migiRyokin hidariRyokin migiRyokin String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int GoukeiMasu = sc.nextInt() + 1;
		int ryokinjyoSuu = sc.nextInt();
		int syokaiIti = sc.nextInt();
		List<Integer> ryokinjyoItiList = new ArrayList<Integer>();
		for(int i=0;i<ryokinjyoSuu;i++) {
			ryokinjyoItiList.add(sc.nextInt());
		}
		//左に行く
		int imanoIti = syokaiIti;
		int hidariRyokin = 0;
		while(imanoIti != 0) {
			imanoIti--;
			if(ryokinjyoItiList.contains(imanoIti)) {
				hidariRyokin++;
			}
		}
		//右に行く
		imanoIti = syokaiIti;
		int migiRyokin = 0;
		while(GoukeiMasu != imanoIti) {
			imanoIti++;
			if(ryokinjyoItiList.contains(imanoIti)) {
				migiRyokin++;
			}
		}
		System.out.println((hidariRyokin<migiRyokin)?hidariRyokin:migiRyokin);
	}
}