main :: IO ()
main = do
  [n, m, k] <- map (read :: String -> Integer) . words <$> getLine
  as <- map (read :: String -> Integer) . words <$> getLine
  bs <- map (read :: String -> Integer) . words <$> getLine
  print $ solve k as bs

solve :: Integer -> [Integer] -> [Integer] -> Integer
solve _ [] [] = 0
solve k (a:as) [] = if k >= a then a else 0
solve k [] (b:bs) = if k >= b then b else 0
solve k ass@(a:as) bss@(b:bs)
  | a < b  = if k >= a then a + (solve (k-a) as bss) else 0
  | a >= b = if k >= b then b + (solve (k-b) ass bs) else 0
