import Data.Char

solve :: String -> Int -> Int
solve s k
  | isFirstKCharAll1 = 1
  | otherwise        = digitToInt $ firstCharNot1
  where isFirstKCharAll1 = all (== '1') $ take k s
        firstCharNot1 = head $ filter (/= '1') s

main :: IO ()
main = do
  s <- getLine
  k <- readLn
  print $ solve s k