import java.io.*; import java.util.*; public class Main_yukicoder59 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); final int MAX = 1_000_000; int n = sc.nextInt(); int k = sc.nextInt(); SegmentTree st = new SegmentTree(MAX); for (int i = 0; i < n; i++) { int w = sc.nextInt(); if (w > 0) { if (st.query(w - 1, MAX) < k) { st.update(w - 1, 1); } } else { w = -w; if (st.query(w - 1, w) > 0) { st.update(w - 1, -1); } } } pr.println(st.query(0, MAX)); pr.close(); sc.close(); } private static class SegmentTree { int[] st; int n; SegmentTree(int n) { this.n = 1; while (this.n < n) { this.n *= 2; } st = new int[2 * this.n - 1]; } // i:0-indexed void update(int i, int x) { i = n - 1 + i; st[i] += x; while (i > 0) { i = (i - 1) / 2; st[i] += x; } } // a, b:0-indexed // [a, b) int query(int a, int b) { return query(a, b, 0, 0, n); } private int query(int a, int b, int i, int l, int r) { if (a >= r || b <= l) { return 0; } if (a <= l && b >= r) { return st[i]; } return query(a, b, i * 2 + 1, l, (l + r) / 2) + query(a, b, i * 2 + 2, (l + r) / 2, r); } } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }