#include using namespace std; template class FenwickTree { private: std::vector ft; public: FenwickTree(int sz) : ft(sz + 1, 0) {} void add(int idx, T x) { for (int i = idx + 1; i < static_cast(ft.size()); i += i & -i) { ft[i] += x; } } T operator()(int idx) const { T res = 0; for (int i = idx + 1; i > 0; i -= i & -i) { res += ft[i]; } return res; } }; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; FenwickTree ft(2000000); for (int i = 0; i < N; i++) { int w; cin >> w; if (w > 0) { if (ft(2000000) - ft(w - 1) < K) ft.add(w, 1); } else { w *= -1; if (ft(w) - ft(w - 1) > 0) ft.add(w, -1); } } cout << ft(2000000) << '\n'; return 0; }