program infinity
  implicit none
  character :: s*100
  integer(8) :: k,leng, i, count
  
  read *, s
  read *, k
  count = 0
  leng = len_trim(s)
  do i = 1, leng
    if (s(i:i) == "1") then
      count = i
    else
      exit
    end if 
  end do
  if (count < k) then
    print '(a)', s(count+1:count+1)
  else
    print '(a)', "1"
  end if
  stop
end program infinity