import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

--calc [] [] _ n = n
--calc (a : as) [] t n
--  | a > t = n
--  | otherwise = calc as [] (t - a) (n + 1)
--calc [] (b : bs) t n
--  | b > t = n
--  | otherwise = calc [] bs (t - b) (n + 1)
--calc (a : as) (b : bs) t n
--  | minimum [a, b] > t = n
--  | a >= b = calc (a : as) bs (t - b) (n + 1)
--  | otherwise = calc as (b : bs) (t - a) (n + 1)
--  where
--

fetchBook [] _ = 0
fetchBook (b:bs) k | b > k = 0
                   | otherwise = 1 + fetchBook bs (k-b)

calc [] bs k m' = m'
calc (a:as) bs k m' | m'' > m' = calc as bs k m''
                        | otherwise = calc as bs k  m'
  where
    m'' = length as + fetchBook bs (k - sum as)

getMax :: [Integer] -> Integer -> [Integer]
getMax [] _ = []
getMax (a:as) k | a > k = []
                | otherwise = a : getMax as (k-a)

main = do
  [n, m, k] <- getIntList
  as <- getIntList
  bs <- getIntList
  let as' = reverse(getMax as k)
  let lenAs = length as
  let sumAs = sum as
  if lenAs > 0
    then print $ calc as' bs k (lenAs + fetchBook bs (k-sumAs))
    else print $ fetchBook bs k
