#include"bits/stdc++.h" //#include using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 100000000; int n, k; int bit[1000002]; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i&-i; } return s; } void add(int i, int x) { while (i <= 1000002) { bit[i] += x; i += i&-i; } } int main() { cin >> n >> k; REP(i, 1000002)bit[i] = 0; REP(i, n) { int w; cin >> w; if (w > 0) { if (sum(1000002) - sum(w - 1) < k) { add(w, 1); } else { if (sum(-w) - sum(-w - 1) >= 1) { add(-w, -1); } } } } print(sum(1000002)); return 0; }