#-*- coding: utf-8 -*- class Train(): def __init__(self, K): self.cargo = [] self.K = K def load(self, weight): if len(self.cargo) < self.K: self.cargo.append(weight) self.cargo.sort() elif self.cargo[-self.K] < weight: self.cargo.append(weight) self.cargo.sort() return None def unload(self, weight): if weight in self.cargo: i = self.cargo.index(weight) del self.cargo[i] return None def station(ft, W): if W > 0: ft.load(W) else: ft.unload(-W) def main(N, K): ft = Train(int(K)) for i in range(int(N)): W = int(input()) station(ft, W) return len(ft.cargo) if __name__ == '__main__': print(main(*(input().split())))