import Data.List

main :: IO ()
main = do
    [_, _, k] <- map read . words <$> getLine
    as <- map read . words <$> getLine
    bs <- map read . words <$> getLine
    let as' = takeWhile (\x -> snd x <= k) [(n, sum (take n as)) | n <- [0..length as]]
        bs' = [ (a + b, x + y) | (a, x) <- as', (b, y) <- takeWhile (\y -> x + snd y <= k) [(m, sum (take m bs)) | m <-  [0..length bs]]]
        res = fst $ last $ sortOn snd bs'
    putStrLn $ show res