import Data.List
import Data.Maybe

main :: IO ()
main = do
  s <- getLine
  k <- readLn :: IO Integer
  let none = filter (/='1') s
      noneId = findIndex (/='1') s

  putChar $ if null none
    then '1'
    else if fromJust (noneId) <= fromIntegral k 
      then head none
      else '1'

  putStrLn ""