N, K = map(int, raw_input().split()) MX = 1000000 data = [0] * (MX + 1) for _ in xrange(N): W = int(raw_input()) if W > 0: if data[W:] < K: data[W] += 1 elif W < 0: if data[-W] > 0: data[-W] -= 1 print sum(data)