import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines class BinaryIndexedTree(): def __init__(self, n): self.node = [0 for _ in range(n+1)] def sum(self, i): ret = 0 while i > 0: ret += self.node[i] i -= i & -i return ret def add(self, i, x): while i < len(self.node): self.node[i] += x i += i & -i n, K = map(int, readline().split()) w = map(int, read().split()) MAX = 1000010 bit = BinaryIndexedTree(MAX) for x in w: if x > 0: if bit.sum(MAX) - bit.sum(x-1) < K: bit.add(x, 1) else: x = -x if bit.sum(x) - bit.sum(x-1) >= 1: bit.add(x, -1) print(bit.sum(MAX))