import Control.Monad
import Data.Char

main = do
    s <- getLine
    k <- read <$> getLine
    putStrLn $ show $ digitToInt $ solve s k

solve :: String -> Int -> Char
solve (h:t) k | k == 0    = h
              | h /= '1'  = h
              | otherwise = solve t k