
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
--import Data.List
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  [_, _, k] <- map read . words <$> getLine
  a <- map read . words <$> getLine
  b <- map read . words <$> getLine
  --a `traceShow`
  print $ solve k a b

solve :: Int -> [Int] -> [Int] -> Int
solve k a b = search 0 k a b


search :: Int -> Int -> [Int] -> [Int] -> Int
search !s _ [] [] = s
search !s !k (a:as) [] = if k < a then s else search (s + 1) (k - a) as []
search !s !k [] bl@(b:bs) = search s k bl []
search !s !k al@(a:as) bl@(b:bs) = if k < mn then s else search (s + 1) (k - mn) al' bl'
  where
    (mn, al', bl') = if a < b then (a, as, bl) else (b, al, bs)
