implicit none

integer,parameter :: PRECINT = 8
integer(PRECINT) :: k
character(100) :: s
integer :: n, i, a
integer(PRECINT) :: m

read *,s
read *,k

n = len_trim(s)

m = 0
do i = 1, n
   read(s(i:i),*) a
   if (a == 1) then
      m = m + 1
      if (m >= k) then
         write(6,'(i0)') 1
         exit
      endif
   else
      write(6,'(i0)') a
      exit
   endif
enddo
stop
end