cnt :: [Int] -> (Int,Int)
cnt [] = (0,1)
cnt (n:ns) = if n == 1 then (1+ (fst (cnt ns)),1)
  else (0,n)

main :: IO ()
main = do
  ns <- map read.words<$> getLine :: IO Int
  k <-readLn :: IO Int
  if fst( cnt ns )>= k then print 1 else print $ snd (cnt ns)