import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc [] [] _ n = n
calc (a : as) [] t n
  | a > t = n
  | otherwise = calc as [] (t - a) (n + 1)
calc [] (b : bs) t n
  | b > t = n
  | otherwise = calc [] bs (t - b) (n + 1)
calc (a : as) (b : bs) t n
  | minimum [a, b] > t = n
  | a >= b = calc (a : as) bs (t - b) (n + 1)
  | otherwise = calc as (b : bs) (t - a) (n + 1)

main = do
  [n, m, k] <- getIntList
  as <- getIntList
  bs <- getIntList
  print $ calc as bs k 0
