program prob3
    implicit none
    character(len=105)::s
    integer::i, l, mode, cnt, tmp
    integer(16)::k
    read(*,*) s
    read(*,*) k
    l = len_trim(s)
    cnt = 0
    mode = 0
    do i = 1, l
        if(s(i:i) == "1" .and. mode == 0) then
            cnt = cnt + 1
        else
            mode = 1
            tmp = i
            exit
        end if
    end do
    if(cnt >= k) then
        write(*,'(a)') "1"
    else
        write(*,'(a)') trim(adjustl(s(tmp:tmp)))
    end if
    stop
end program