import Data.Char

main :: IO ()
main = getLine >>= main' . map (\c -> ord c - ord '0')
    where
        main' s = readLn >>= print . solve s

solve :: [Int] -> Int -> Int 
solve xs k
    | all (== 1) ys = 1
    | otherwise = head $ filter (/= 1) ys
    where
        ys = take k xs 