#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int main(){ int N, M, a; cin >> N >> M; vector A; rep(i,M){ cin >> a; A.push_back(a); } reverse(ALLOF(A)); int ret = 0; rep(i,A.size()){ if(ret == 0){ ret = A[i]-1; }else if(ret < A[i]){ ret--; } } cout << ret+1 << endl; return 0; }