import java.math.*; import java.util.*; class BIT{ int[] bit=new int[1000001]; void add(int a,int w){; for(int x = a;x<=1000000;x+=(x&-x)) { bit[x] += w; } } int sum(int a){ int ret = 0; for(int x = a;x>0;x -= x& -x) ret += bit[x]; return ret; } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int k = sc.nextInt(); BIT bit = new BIT(); int[] aru = new int[100001]; int ans=0; for(int i=0;i0){ if( (bit.sum(1000000)-bit.sum(temp))>=k) continue; bit.add(temp,1); aru[temp]++; ans++; }else{ if(aru[-temp]>0) { ans--; bit.add(-temp,-1); } } } System.out.println(ans); } }