import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  [n, m, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    cumSum :: [Int] -> [Int]
    cumSum = unfoldr next . (,) 0
      where
        next :: (Int, [Int]) -> Maybe (Int, (Int, [Int]))
        next (acc, x : xs) | acc <= k - x, acc' <- acc + x = Just (acc', (acc', xs))
        next _                                             = Nothing
    go :: Int -> Int -> Int -> [Int] -> [Int] -> Int
    go t i j xs@(x : xs') ys@(y : ys') | y <= k - x = go t i (j + 1) xs ys'
                                       | otherwise  = go (t `max` (i + j)) (i - 1) j xs' ys
    go t 0 j _            ys                        = t `max` (j + length ys)
    go t i j _            []                        = t `max` (i + j)
  as <- cumSum . map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  bs <- cumSum . map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ go 0 (length as) 0 (reverse as) bs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
