import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); TreeMap map = new TreeMap<>(); int count = 0; int max = 0; int maxCount = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (x > 0) { if (count >= k && max >= x) { continue; } if (map.containsKey(x)) { map.put(x, map.get(x) + 1); } else { map.put(x, 1); } if (count < k) { count++; if (count == k) { max = map.firstKey(); maxCount = 0; } } else { count++; maxCount++; if (map.get(max) <= maxCount) { max = map.higherKey(max); maxCount = 0; } } } else { x *= -1; if (map.containsKey(x)) { int cnt = map.get(x); if (cnt == 1) { map.remove(x); } else { map.put(x, cnt - 1); } count--; } else { continue; } if (count >= k && max <= x) { maxCount--; if (maxCount < 0) { max = map.lowerKey(max); maxCount = map.get(max) - 1; } } } } System.out.println(count); } }