program tsundoku
  implicit none
  integer, parameter :: infty = 1100100100
  integer :: n, m, i = 1, j = 1, x = 0
  integer(8) :: k, t = 0
  integer(8), dimension(200001) :: a = 0, b = 0
  read(*,*) n, m, k
  read(*,*) a(1:n)
  read(*,*) b(1:m)
  a(n + 1) = infty
  b(m + 1) = infty
  do
    if (a(i) < b(j)) then
      if (t + a(i) > k) exit
      t = t + a(i)
      i = i + 1
      x = x + 1
    else
      if (t + b(j) > k) exit
      t = t + b(j)
      j = j + 1
      x = x + 1
    end if
  end do
  write(*,'(i0)') x
end program tsundoku