module mod_radix_sort
  implicit none
  integer, private, parameter :: intkind = 8
  integer, private, parameter :: nbit = 8
  integer, private, parameter :: upper = lshift(1, nbit) - 1
contains
  subroutine radix_sort(a)
    integer(intkind), intent(inout) :: a(:)
    integer(intkind), allocatable :: queue(:, :)
    integer :: n, m, i, j, k, cnt(0:upper)
    n = size(a)
    m = 0
    do i = 0, 8 * intkind - 1, nbit
      cnt = 0
      do j = 1, n
        k = and(rshift(a(j), i), upper)
        cnt(k) = cnt(k) + 1
      end do
      m = max(m, maxval(cnt))
    end do
    allocate(queue(m, 0:upper))
    do i = 0, 8 * intkind - 1, nbit
      cnt = 0
      do j = 1, n
        k = and(rshift(a(j), i), upper)
        cnt(k) = cnt(k) + 1
        queue(cnt(k), k) = a(j)
      end do
      k = 0
      do j = 0, upper
        if (cnt(j) == 0) cycle
        a(k + 1:k + cnt(j)) = queue(1:cnt(j), j)
        k = k + cnt(j)
      end do
    end do
  end
end module mod_radix_sort
program voting_judges
  use mod_radix_sort
  integer :: n, v, p, i, l, r, x
  integer(8) :: m, s, a(100000) = 0, y
  read(*,*) n, m, v, p
  read(*,*) a(1:n)
  call radix_sort(a(1:n))
  a(1:n) = a(n:1:-1)
  l = p
  r = n + 1
  do i = p + 1, n
    if (a(i) + m < a(p)) then
      r = i
    end if
  end do
  do while (r - l > 1)
    x = (l + r) / 2
    s = sum(a(x) + m - a(p:x - 1))
    y = max(m * (v - p - n + x), 0_8)
    if (s < y) then
      r = x
    else
      l = x
    end if
  end do
  write(*,'(i0)') l
end program voting_judges