main :: IO ()
main = do
  -- input number
  [n, m, k] <- map (read :: String -> Int) . words <$> getLine
  an <- map (read :: String -> Int) . words <$> getLine
  bm <- map (read :: String -> Int) . words <$> getLine
  print $ maxReadingBooks an bm k

maxReadingBooks :: [Int] -> [Int] -> Int -> Int
maxReadingBooks [] [] _ = 0
maxReadingBooks [] (b:bi) k = if k-b > 0 then 1 + maxReadingBooks [] bi (k-b)
                              else 0
maxReadingBooks (a:ai) [] k = if k-a > 0 then 1 + maxReadingBooks ai [] (k-a)
                              else 0                                   
maxReadingBooks (a:ai) (b:bi) k
  | a > b = if k-b > 0
            then 1 + maxReadingBooks (a:ai) bi (k-b)
            else 0
  | otherwise = if k-a > 0
                then 1 + maxReadingBooks ai (b:bi) (k-a)
                else 0
