import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m,k] <- getIntList
    as <- getIntList
    bs <- getIntList
    let sa = takeWhile (< k) $ scanl (+) 0 as
        sb = tail $ scanl (+) 0 bs
        ans = zipWith (\a i -> i + length (takeWhile (< k-a) sb)) sa [0..]
    print $ maximum ans