#include <bits/stdc++.h>

using namespace std;
// Constants and macros
#define INF 		(int)1e9
#define EPS 		1e-9
#define bitcount 	__builtin_popcount
#define gcd 		__gcd
#define forall(i,a,b) 	for(int i=a;i<b;i++)
#define pb 		push_back
#define mp		make_pair
#define MAX(a,b)	( (a)>(b) ? (a):(b))
#define MIN(a,b)	( (a)<(b) ? (a):(b))
#define s(a)		scanf("%d", &a)
#define ss(a,b)		scanf("%d %d", &a,&b)
#define sss(a,b,c)	scanf("%d %d %d", &a,&b,&c)
#define sl(a)		scanf("%I64d", &a)

int G, P;
int gate[100005];

int main(){
	ss(G,P);
	int pl;
	forall(i, 0, P){
		s(pl);
		pl = MIN(pl,G);
		while(gate[pl]){
			pl--;
			if (pl ==0) {
				printf("%d", i);
				return 0;
			}
		}
		//cout << i << " " << pl << endl;
		gate[pl]=1;
	}
	printf("%d", P);
}