main :: IO ()
main = do
  k <- readLn
  n <- readLn
  let ks = reverse $ toNumList k
  print $ solve n ks

toNumList 0 = []
toNumList n = (n `mod` 10) : toNumList (n `div` 10)

solve :: Int -> [Int] -> Int
solve 0 (k:ks) = k
solve n (k:ks)
  | k == 1 = solve (n - 1) ks
  | otherwise = k
