      PROGRAM tsundoku
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: ans,n,m,i,j, k,time, caseNum
      integer(p),allocatable :: a(:),b(:)
      
      
      read*,n,m,k
      allocate( a(n),b(m) )
      read*,a(1:n)
      read*,b(1:m)
      
      a(1:n) = a(n:1:-1)
      b(1:m) = b(m:1:-1)
      
      i = n
      j = m
      ans = 0
      time = 0
      do while( .true. )
        if( i==0 ) caseNum = 2
        if( j==0 ) caseNum = 1
        
        if( a(i)<=b(j) )then
          caseNum = 1
        else
          caseNum = 2
        end if
        
        select case( caseNum )
          case( 1 )
            time = time + a(i)
            i = max( 0,i-1 )
          case( 2 )
            time = time + b(j)
            j = max( 0,j-1 )
        end select
        
      !  print*,caseNum,i,j
        
        if( time>k )then
          exit
        end if
        
        if( i==0.and.j==0 )then
          if( time<=k )then
            ans = ans + 1
          end if
          exit
        end if
        
        ans = ans + 1
      end do
      
      print*,ans
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM