#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; using ll = long long; int main() { int n,m; cin >> n >> m; int pos = 1; vector shl(m); for(auto&& x : shl) cin >> x; for(int i = m-1; i >= 0; --i) { if(pos == 1) pos = shl.at(i); else if(shl[i] >= pos) --pos; } cout << pos << endl; }