import Control.Monad
import Data.Maybe
import Data.List

-- firstBinary :: (Int -> Bool) -> Int -> Int -> Int
firstBinary _ l r | l == r = l
firstBinary f l r = let m = div (l + r) 2 in if f m then firstBinary f l m else firstBinary f (m + 1) r

f :: String -> (Int, Maybe Char)
f "" = (0, Nothing)
f ('1':s) = let (n, c) = f s in (n + 1, c)
f (c:s) = (0, Just c)

main = do
    s  <- getLine
    n  <- read <$> getLine
    let (one, c) = f s
    putStrLn $ if n <= one then "1" else [fromJust c]
