import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from copy import deepcopy n, k = map(int, input().split()) w = [int(input()) for i in range(n)] bit_max = 1000000 d = [0] * (bit_max + 1) def bit_add(bit_add_x, bit_add_val): while bit_add_x <= bit_max: d[bit_add_x] += bit_add_val bit_add_x += bit_add_x & (-bit_add_x) def bit_sum(bit_sum_x): bit_sum_total = 0 while bit_sum_x > 0: bit_sum_total += d[bit_sum_x] bit_sum_x = bit_sum_x & bit_sum_x - 1 return bit_sum_total for ww in w: if ww > 0: ww -= 1 if bit_sum(bit_max - ww) < k: bit_add(bit_max - ww, 1) elif ww < 0: ww += 1 if bit_sum(bit_max + ww) - bit_sum(bit_max + ww - 1) > 0: bit_add(bit_max + ww, -1) print(bit_sum(bit_max))