from collections import defaultdict
class BinaryIndexedTree:
    def __init__(self, N):
        self.sz = N
        self.bit = [0] * (N + 1)

    def Sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def Add(self, i, x):
        i += 1
        while i <= self.sz:
            self.bit[i] += x
            i += i & -i

INF = 10**6
N,K = map(int,input().split())
BIT = BinaryIndexedTree(INF)
cnt = defaultdict(int)
for _ in range(N):
    W = int(input())
    if W < 0:
        W = abs(W)
        if cnt[W] > 0:
            BIT.Add(W, -1)
            cnt[W] -= 1
    else:
        if BIT.Sum(INF) - BIT.Sum(W) < K:
            BIT.Add(W, 1)
            cnt[W] += 1
print(BIT.Sum(INF))