program to_infinity
  implicit none
  character(100) :: s
  integer(8) :: k
  integer :: i, m
  read(*,'(a)') s
  read(*,*) k
  m = int(min(k,len_trim(s)))
  do i = 1, m
    if (s(i:i) == "1") cycle
    write(*,'(a)') s(i:i)
    stop
  end do
  write(*,'(i0)') 1
end program to_infinity