program handstand
  implicit none
  integer :: n, k, a(100000) = 0, b(0:100000) = 0, m = 0, x = 0, i, j
  character(100001) :: s
  read(*,*) n, k
  read(*,'(a)') s
  s(n+1:n+1) = "X"
  i = 1
  do j = 2, n+1
    if (s(j:j) == s(j-1:j-1)) cycle
    m = m+1
    a(m) = (2*(ichar(s(i:i))-48)-1)*(j-i)
    i = j
  end do
  do i = 1, m
    b(i) = b(i-1)+abs(a(i))
  end do
  do i = 1, m
    if (a(i) > 0) then
      x = max(x,b(min(i+2*k,m))-b(i-1))
    else
      x = max(x,b(min(i+2*k-1,m))-b(i-1))
    end if
  end do
  write(*,'(i0)') x
end program handstand