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): while i <= self.sz: self.bit[i] += x i += i & -i INF = 10**6 N,K = map(int,input().split()) BIT = BinaryIndexedTree(INF) for _ in range(N): W = int(input()) if W < 0: W = abs(W) if BIT.Sum(W) - BIT.Sum(W-1) > 0: BIT.Add(W, -1) else: if BIT.Sum(INF) - BIT.Sum(W-1) < K: BIT.Add(W, 1) print(BIT.Sum(INF))