#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define int long long
#define bochi_orz cin.tie(0);cin.sync_with_stdio(0);
signed main() {
bochi_orz
int n, q;
cin >> n >> q;
vector<int> queries(q);
set<int> st;
int cnt = 0;
for (int i = 0; i < q; i++){
int x;
cin >> x;
if (x > 0){
if (st.find(x) != st.end()){
st.clear();
cnt++;
}
st.insert(x);
}
else{
if (st.find(-x) != st.end()){
st.erase(-x);
}
}
}
cout << cnt << "\n";
}
/*
____ ___ ___ ____ _____ ____ ____ ___
| | | | \ | | /| | | | \
| | | | | |____ | | | _ |____ |___/
| | | | | | | | | | | | \
|____ |___| |___/ |____ | __|__ |____| |____ | \
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |