N, K = map(int, input().split()) M = 10 ** 6 + 1 B = [0] * M C = [0] * M def A(a, w): while a < M: B[a] += w a += a & (-a) def S(a): r = 0 while a > 0: r += B[a] a -= a & (-a) return r while N: N -= 1 w = int(input()) if w > 0: if S(M - w) < K: A(M - w, 1) C[w] += 1 else: if C[-w] > 0: A(M + w, -1) C[-w] -= 1 print(S(M - 1))