#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<stack>
#include<queue>
#include<string.h>
#include<array>
#include<algorithm>
#include<cmath>
using namespace std;
#define ff first
#define ss second
const int maxn = 5e5;
int maxq = 29;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> a(q);
set<int> st;
for(int i = 0; i < q; i++){
cin >> a[i];
}
int ans = 0;
for(int i = 0; i < q; i++){
if(a[i] > 0){
if(st.count(a[i]) > 0){
ans += 1;
st.clear();
}
st.insert(a[i]);
}
else{
st.erase(-a[i]);
}
}
cout << ans;
}