import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	} main {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int X = scn.nextInt(); X scn.nextInt() scn.nextInt scn int N = scn.nextInt(); N scn.nextInt() scn.nextInt scn int[] arr = new int[N]; arr new int[N] N for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			arr[i] = scn.nextInt();
		} {
			arr[i] = scn.nextInt();
		} arr[i] = scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn int ans = Val(N, X, arr); ans Val(N, X, arr) Val N X arr System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	} Val {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	} if (N == 0) {
			return X;
		} N == 0 N 0 {
			return X;
		} return X; X quickSort(arr, 0, N - 1) quickSort arr 0 N - 1 N 1 int val = X + 1; val X + 1 X 1 int val1 = X; val1 X boolean start = false; start false while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		} true {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		} val = val - 1 val val - 1 val 1 int bs = binarySearch(arr, 0, N - 1, val); bs binarySearch(arr, 0, N - 1, val) binarySearch arr 0 N - 1 N 1 val if (bs == -1) {
				return val;
			} bs == -1 bs -1 1 {
				return val;
			} return val; val if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			} start {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			} val1 = val1 + 1 val1 val1 + 1 val1 1 int bs1 = binarySearch(arr, 0, N - 1, val1); bs1 binarySearch(arr, 0, N - 1, val1) binarySearch arr 0 N - 1 N 1 val1 if (bs1 == -1) {
					return val1;
				} bs1 == -1 bs1 -1 1 {
					return val1;
				} return val1; val1 start = true start true int N N int X X int[] arr arr public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	} binarySearch {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	} if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		} r >= l r l {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		} int mid = l + (r - l) / 2; mid l + (r - l) / 2 l (r - l) / 2 (r - l) r l 2 if (arr[mid] == x)
				return mid; arr[mid] == x arr[mid] arr mid x return mid; mid if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x); arr[mid] > x arr[mid] arr mid x return binarySearch(arr, l, mid - 1, x); binarySearch(arr, l, mid - 1, x) binarySearch arr l mid - 1 mid 1 x return binarySearch(arr, mid + 1, r, x); binarySearch(arr, mid + 1, r, x) binarySearch arr mid + 1 mid 1 r x return -1; -1 1 int arr[] arr int l l int r r int x x public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	} quickSort {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	} if (lo >= hi) {
			return;
		} lo >= hi lo hi {
			return;
		} return; int mid = (lo + hi) / 2; mid (lo + hi) / 2 (lo + hi) lo hi 2 int pivot = arr[mid]; pivot arr[mid] arr mid int left = lo; left lo int right = hi; right hi while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		} left <= right left right {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		} while (arr[left] < pivot) {
				left++;
			} arr[left] < pivot arr[left] arr left pivot {
				left++;
			} left++ left while (arr[right] > pivot) {
				right--;
			} arr[right] > pivot arr[right] arr right pivot {
				right--;
			} right-- right if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			} left <= right left right {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			} int temp = arr[left]; temp arr[left] arr left arr[left] = arr[right] arr[left] arr left arr[right] arr right arr[right] = temp arr[right] arr right temp left++ left right-- right quickSort(arr, lo, right) quickSort arr lo right quickSort(arr, left, hi) quickSort arr left hi int[] arr arr int lo lo int hi hi public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt();
		int N = scn.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = scn.nextInt();
		}
		int ans = Val(N, X, arr);
		System.out.println(ans);
	}

	public static int Val(int N, int X, int[] arr) {
		if (N == 0) {
			return X;
		}
		quickSort(arr, 0, N - 1);
		int val = X + 1;
		int val1 = X;
		boolean start = false;
		while (true) {
			val = val - 1;
			int bs = binarySearch(arr, 0, N - 1, val);
			if (bs == -1) {
				return val;
			}
			if (start) {
				val1 = val1 + 1;
				int bs1 = binarySearch(arr, 0, N - 1, val1);
				if (bs1 == -1) {
					return val1;
				}
			}
			start = true;
		}
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static void quickSort(int[] arr, int lo, int hi) {
		if (lo >= hi) {
			return;
		}
		int mid = (lo + hi) / 2;
		int pivot = arr[mid];
		int left = lo;
		int right = hi;
		while (left <= right) {
			while (arr[left] < pivot) {
				left++;
			}
			while (arr[right] > pivot) {
				right--;
			}
			if (left <= right) {
				int temp = arr[left];
				arr[left] = arr[right];
				arr[right] = temp;
				left++;
				right--;
			}
		}
		quickSort(arr, lo, right);
		quickSort(arr, left, hi);
	}
}