program main implicit none integer::N,K,ans=0,ref,i,j integer,allocatable::P(:) read*,N,K allocate(P(N)) read*,P do i=minval(P)-1,maxval(P)+1 ref=0 do j=1,N if(P(j)>=i)ref=ref+1 end do if(ref<=K)ans=max(ans,ref) end do print'(i0)',ans end program main