import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} import java.util.*; util.* java public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} Main static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	} solve {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt() N sc.nextInt() sc.nextInt sc M = sc.nextInt() M sc.nextInt() sc.nextInt sc X = sc.nextInt() X sc.nextInt() sc.nextInt sc no = M no M t1=0 t1 0 t2=0; t2 0 Set<Integer> s = new HashSet<Integer>(); s new HashSet<Integer>() while (no-->0) s.add(sc.nextInt()); no-->0 no-- no 0 s.add(sc.nextInt()) s.add s sc.nextInt() sc.nextInt sc if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		} X!=1 || X!=N-1 X!=1 X 1 X!=N-1 X N-1 N 1 {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		} for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++; int i=X+1; int i=X+1; i X+1 X 1 i<=N i N i++ i++ i if (s.contains(i)) t1++; if (s.contains(i)) t1++; s.contains(i) s.contains s i t1++ t1 for (int i=X-1; i>0; i--) if (s.contains(i)) t2++; int i=X-1; int i=X-1; i X-1 X 1 i>0 i 0 i-- i-- i if (s.contains(i)) t2++; if (s.contains(i)) t2++; s.contains(i) s.contains s i t2++ t2 System.out.println(Math.min(t1,t2)) System.out.println System.out System System.out Math.min(t1,t2) Math.min Math t1 t2 sc.close() sc.close sc public static void main(String args[]) {
		solve();
	} main {
		solve();
	} solve() solve String args[] args public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} Main
import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt(), no = M, t1=0, t2=0;
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) s.add(sc.nextInt());
		if (X!=1 || X!=N-1) {
			for (int i=X+1; i<=N; i++) if (s.contains(i)) t1++;
			for (int i=X-1; i>0; i--) if (s.contains(i)) t2++;
		}
		System.out.println(Math.min(t1,t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}