program main
implicit none
integer :: n, k
character :: s*100000

integer :: i, j, nc, chank, c, m, a
integer , allocatable :: t( : ), u( : )
read(*,*) n, k
read(*,*) s(1:n)
allocate( t(n+1) )

chank = 0
nc = 1
t = 0
do i = 2, n-1
   if( s(i:i) == s(i-1:i-1) ) then
      nc = nc + 1
   else
      chank = chank+1
      t( i ) = nc
      nc = 1 
   end if
end do
if( s(n:n) == s(n-1:n-1) ) then
   chank = chank + 1
   t( n+1 ) = nc+1
else
   t( n ) = nc
   t( n+1 ) = 1
   chank = chank + 2
end if
allocate( u(chank) )

nc = 0
u  = 0
do i = 1, n+1
   if( t( i ) /= 0 ) then
      nc = nc+1
      u(nc) = t(i)
   end if
end do

if( s(1:1) == '1' ) then
   c = 2*k+1
   if( c .ge. chank ) then
      write(*,*) n
      stop
   else
      m = 0
      do j = k+1, chank-k
         if( m .le. sum( u(max(1,j-k):min(chank,j+k)) ) ) then
            m = sum( u(max(1,j-k):min(chank,j+k)) )
         end if
      end do
      write(*,'(i0)') m
   end if
   
else
   c = 2*k
   if( c .ge. chank ) then
      write(*,'(i0)') n
      stop
   else
      m = 0
      do j = k+1, chank-k
         if( max(1,j-k) == 1 ) then
            m = sum(u(1:2*k) )
         else if( m .le. sum( u(max(2,j-k):min(chank,j+k)) ) ) then
            m = sum( u(max(2,j-k):min(chank,j+k)) )
         else if( min( chank, j+k) == chank ) then
            if( m.le. sum( u(chank-2*k+1:chank) ) ) then
               m = sum( u(chank-2*k+1:chank) )
               stop
            end if
         end if
      end do
      write(*,'(i0)') m
   end if
end if
end program main
