import           Control.Monad (replicateM)
import           Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main :: IO ()
main = do
  [n, m, k] <- map read . words <$> getLine
  [as, bs] <- replicateM 2 $ scanl1 (+) . takeWhile (<= k) <$> getIntList
  let ans1 = (maximum . map (length . takeWhile (<= k))) [as, bs]
      ans2 = maximum
        $ (++) [0] -- for empty list
        $ zipWith (+) [1 ..]
        $ (flip map) ((takeWhile (<= k)) as)
        $ \n -> (length . takeWhile (<= k - n)) bs
  print $ max ans1 ans2
