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 $ scanl (+) 0 . takeWhile (<= k) <$> getIntList
  let ans = maximum
        $ zipWith (+) [0 ..]
        $ (flip map) as
        $ \n -> (f . takeWhile (<= k - n)) bs
  print ans
  where
    f [] = 0
    f l = length l - 1
