import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) import collections D=collections.defaultdict(int) W=[int(input()) for _ in range(n)] WW=sorted(list(set([abs(i) for i in W]))) for i,ww in enumerate(WW): D[ww]=i+1 n_max=10**5 nn=n_max.bit_length()+1 BIT=[0]*(2**nn) BIT.insert(0,0) # i が与えられたとき a1~aiまでの和を計算する( O(log n) ) def bitsum(BIT,i): s=0 while i>0: s+=BIT[i] i-=i&(-i) return s # i と x が与えられたとき ai += x とする ( O(log n) ) def bitadd(BIT,i,x): while i<=2**nn: BIT[i]+=x i+=i&(-i) return BIT for i,w in enumerate(W): ind=D[abs(w)] if w<0: if ind==1: if bitsum(BIT,ind)>0: bitadd(BIT,ind,-1) elif bitsum(BIT,ind)-bitsum(BIT,ind-1)>0: bitadd(BIT,ind,-1) else: if bitsum(BIT,n)-bitsum(BIT,ind-1)>=k: continue else: bitadd(BIT,ind,1) print(bitsum(BIT,n))