import Data.List
main=do
  s<-getLine
  k<-readLn::IO Int
  putStrLn $ if length s == 1
    then s
    else case (f s,k) of
        (('1',_),1) -> "1"
        (('1',b),_) -> [b]
        ((a,_),_)   -> [a]

f (a:b:_) = (a,b)
