import strutils,sequtils,math const x21 = 1 shl 21 x20 = 1 shl 20 var N,K : int flag : array[100001,int] nimotu = newSeq[int](0) BIT : array[x21,int] cnt,w,index : int (N,K) = stdin.readline.strip.split.map(parseInt) proc hantei(i : int):bool= var j = i cnt = BIT[i] while (j and (j + 1)) > 0: if (j and 1) == 1: j = (j + 1) shr 1 cnt += BIT[j] else: j += 1 cnt += BIT[j] return cnt < K for n in 1..N: w = stdin.readline.parseInt if w > 0: index = x20 + w if hantei(index): while index > 0: BIT[index] += 1 index = index shr 1 cnt += 1 else: index = x20 - w if BIT[index] > 0: while index > 0: BIT[index] -= 1 index = index shr 1 cnt -= 1 echo cnt