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

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