#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector a(n); 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; return 0; }