main = do
    [n,m,k] <- map read . words <$> getLine :: IO [Int]
    as <- map read . words <$> getLine :: IO [Int]
    bs <- map read . words <$> getLine :: IO [Int]
    print $ solve as bs 0 k

solve :: [Int] -> [Int] -> Int -> Int -> Int
solve [] [] time timeMax = 0
solve (x:xs) [] time timeMax | (time + x) > timeMax = 0
                             | otherwise = 1 + solve (x:xs) [] (time + x) timeMax
solve [] (y:ys) time timeMax | (time + y) > timeMax = 0
                             | otherwise = 1 + solve [] ys (time + y) timeMax
solve (x:xs) (y:ys) time timeMax | x < y && (time + x) <= timeMax = 1 + solve xs (y:ys) (time + x) timeMax
                                 | x >= y && (time + y) <= timeMax = 1 + solve (x:xs) ys (time + y) timeMax
                                 | otherwise = 0

