solve :: [Integer] -> [Integer] -> Integer -> Integer -> Int -> Int
solve s t currentTime timeLimit ans
 | s == [] && t == [] = ans
 | s == [] = if (timeLimit < currentTime + head t) then ans else solve s (tail t) (currentTime + head t) timeLimit (ans + 1) 
 | t == [] = if (timeLimit < currentTime + head s) then ans else solve (tail s) t (currentTime + head s) timeLimit (ans + 1)  
 | (head s) > (head t) = if (timeLimit < currentTime + head t) then ans else solve s (tail t) (currentTime + head t) timeLimit (ans + 1) 
 | (head t) >= (head s) = if (timeLimit < currentTime + head s) then ans else solve (tail s) t (currentTime + head s) timeLimit (ans + 1) 

main :: IO ()
main = do 
 [_,_,k] <- map read . words <$> getLine :: IO [Integer]
 ak <- map read . words <$> getLine :: IO [Integer]
 bk <- map read . words <$> getLine :: IO [Integer]
 print $ solve ak bk 0 k 0