import Data.List
readIntList :: IO [Int]
readIntList = map read . words <$> getLine

f :: [Int] -> [Int] -> Int -> Int -> Int
f (a:as) (b:bs) count limit
   | a <= b && limit >= a = f as ([b] ++ bs) (count + 1) (limit - a)
   | a > b && limit >= b = f ([a] ++ as) bs (count + 1) (limit - b)
   | otherwise = count
f [] b count limit = f1 b count limit
f a [] count limit = f1 a count limit

f1 :: [Int] -> Int -> Int -> Int
f1 (x:xs) count limit
   | limit >= x = f1 xs (count + 1) (limit - x )
   | otherwise = count
f1 [] count limit = count
 
main = do
    [_, _, k] <- readIntList
    a <- readIntList
    b <- readIntList
    let ret = f a b 0 k
    print ret