#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n,q;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
set<int>sm,bg;
set<int>overt;
for(int i = 1;i < n;i++) bg.insert(i);
int ans = 0;
while(q--){
int x; cin >> x;
if(x > 0){
if(bg.find(x) != bg.end()){
bg.erase(x);
sm.insert(x);
continue;
}
if(overt.empty() or (overt.find(x) != overt.end())){
ans++;
overt.clear();
}
overt.insert(x);
}
else {
x *= -1;
if(bg.find(x) != bg.end()) continue;
sm.erase(x);
bg.insert(x);
if(overt.find(x) != overt.end()) overt.erase(x);
}
}
cout<<ans;
}