#include #include #include 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]; if (pos <= A[i]) { pos--; } } cout << pos << endl; return 0; }