program main
implicit None
	character(len = 100)::s
	integer(8)::k,i,n,c = 1
	
	read*,s
	read*,k
	n = len_trim(s)
	
	if(k < n) n = k
	
	do i = 1,n
		if(s(i:i) /= "1")then
			read(s(i:i),*) c
			exit
		endif
	enddo
	
	print "(i0)",c
	
end program main