import qualified Data.ByteString.Char8 as C
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed ((!))
main = sol <$> get <*> get <*> get >>= print
get = U.unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine
sol nmk a b = f k 0 0
  where
  n = nmk!0
  m = nmk!1
  k = nmk!2
  f t i j
    | t < 0     = i+j-1
    | i == n    = g t b m (j+1) n
    | j == m    = g t a n (i+1) m
    | otherwise = f (t-dt) i' j'
    where
    (dt, i', j') = if a!i < b!j then (a!i, i+1, j) else (b!j, i, j+1)
  g t v bnd ix ix'
    | t < 0     = ix+ix'-1
    | ix==bnd   = ix+ix'
    | otherwise = g (t-v!ix) v bnd (ix+1) ix'