#include "bits/stdc++.h" using namespace std; int main() { int N, M; cin >> N >> M; vector A(M); for (int i = 0; i < M; i++) { cin >> A[i]; } int pos = 1; for (int i = M - 1; i >= 0; i--) { if (pos == 1) pos = A[i]; else{ if (A[i] >= pos) pos--; } } cout << pos << endl; }