You are given an array a with n elements. Each element of a is either 0 or 1.

Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).


-----Input-----

The first line contains two integers n and k (1 ≤ n ≤ 3·10^5, 0 ≤ k ≤ n) — the number of elements in a and the parameter k.

The second line contains n integers a_{i} (0 ≤ a_{i} ≤ 1) — the elements of a.


-----Output-----

On the first line print a non-negative integer z — the maximal value of f(a) after no more than k changes of zeroes to ones.

On the second line print n integers a_{j} — the elements of the array a after the changes.

If there are multiple answers, you can print any one of them.


-----Examples-----
Input
7 1
1 0 0 1 1 0 1

Output
4
1 0 0 1 1 1 1

Input
10 2
1 0 0 1 0 1 0 1 0 1

Output
5
1 0 0 1 1 1 1 1 0 1

Difficulty: MEDIUM_HARD

Solutions:
(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
z = 0
zeros = []
for i in range(n):
	if arr[i] == 1:
		z += 1
	else:
		zeros.append([i, z])
		if len(zeros) > 1:
			zeros[-2].append(z)
		z = 0
try:
	zeros[-1].append(z)
except:
	print(n)
	print(*arr)
	exit()
if k == 0:
	print(max(max(zeros, key=lambda x: max(x[1], x[2]))[1:]))
	print(*arr)
elif len(zeros) <= k:
	print(n)
	print(*[1 for i in range(n)])
else:
	maxi = [-1, -1]
	for i in range(len(zeros) - k + 1):
		diff = zeros[i][1] + zeros[i + k - 1][2] + zeros[i + k - 1][0] - zeros[i][0] + 1
		if diff > maxi[0]:
			maxi = [diff, i]
	for i in range(zeros[maxi[1]][0], zeros[maxi[1] + k - 1][0] + 1):
		arr[i] = 1
	print(maxi[0])
	print(*arr)


(n, k) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
l = 0
ans = 0
resL = -1
resR = -1
cntZero = 0
for r in range(n):
	if a[r] == 0:
		cntZero += 1
	while cntZero > k:
		if a[l] == 0:
			cntZero -= 1
		l += 1
	if ans < r - l + 1:
		ans = r - l + 1
		resL = l
		resR = r
print(ans)
if resL != -1:
	for i in range(resL, resR + 1):
		a[i] = 1
for i in range(n):
	print(a[i], end=' ')


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split()))
arr = [-1]
for i in range(n):
	if a[i] == 0:
		arr.append(i)
arr.append(n)
if len(arr) - 2 <= k:
	ans = [1] * n
	print(n)
	print(*ans)
else:
	x = len(arr)
	ans = 0
	start = 0
	end = -1
	for i in range(k + 1, x):
		if ans < arr[i] - arr[i - k - 1] - 1:
			start = arr[i - k - 1] + 1
			end = arr[i] - 1
			ans = arr[i] - arr[i - k - 1] - 1
	for i in range(start, end + 1):
		a[i] = 1
	print(ans)
	print(*a)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
r = -1
ans = 0
ans_po = 0
for l in range(n):
	if l > 0:
		if a[l - 1] == 0:
			m += 1
	while r < n - 1 and 1 - a[r + 1] <= m:
		r += 1
		if a[r] == 0:
			m = m - 1
	if r - l + 1 > ans:
		ans = r - l + 1
		ans_po = l
print(ans)
for i in range(ans_po, ans_po + ans):
	a[i] = 1
print(' '.join(map(str, a)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(x, y, m, ans) = (0, 0, 0, [0, 0])
while x < n:
	while y < n and (k > 0 or a[y] == 1):
		if a[y] == 0:
			k -= 1
		y += 1
	if y - x > m:
		ans = [x, y]
		m = y - x
	if a[x] == 0:
		k += 1
	x += 1
a[ans[0]:ans[1]] = [1] * (ans[1] - ans[0])
print(ans[1] - ans[0])
print(' '.join(map(str, a)))


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
(n, k) = li()
a = li()
cnt0 = 0
l = 0
max_len = 0
end = None
start = None
for i in range(n):
	if a[i] == 0:
		cnt0 += 1
	while cnt0 > k:
		if a[l] == 0:
			cnt0 -= 1
		l += 1
	if i - l + 1 > max_len:
		max_len = i - l + 1
		end = i
		start = l
if max_len > 0 and start is not None and (end is not None):
	for i in range(start, end + 1):
		a[i] = 1
print(max_len)
print_list(a, ' ')


import sys
sys.stderr = sys.stdout
from collections import deque

def hard(n, k, A):
	D = deque()
	z = 0
	m = 0
	b = (0, 0)
	i = 0
	for j in range(n):
		if A[j] == 0:
			if z < k:
				z += 1
			else:
				l = j - i
				if l > m:
					m = l
					b = (i, j)
				while A[i] != 0:
					i += 1
				i += 1
	l = n - i
	if l > m:
		m = l
		b = (i, n)
	for i in range(b[0], b[1]):
		A[i] = 1
	return m

def main():
	(n, k) = readinti()
	A = readintl()
	z = hard(n, k, A)
	print(z)
	print(' '.join(map(str, A)))

def readint():
	return int(input())

def readinti():
	return map(int, input().split())

def readintt():
	return tuple(readinti())

def readintl():
	return list(readinti())

def readinttl(k):
	return [readintt() for _ in range(k)]

def readintll(k):
	return [readintl() for _ in range(k)]

def log(*args, **kwargs):
	print(*args, **kwargs, file=sys.__stderr__)
main()


def main():
	a = [int(x) for x in input().split()]
	legtobb = 0
	b = 0
	c = 0
	sorozat = [int(x) for x in input().split()]
	helyek = []
	helyek.append(-1)
	for x in range(len(sorozat)):
		if sorozat[x] == 0:
			helyek.append(x)
	helyek.append(a[0])
	mo = [0, 0]
	if a[1] >= len(helyek) - 2:
		for x in range(len(sorozat)):
			sorozat[x] = 1
			c = a[0]
	else:
		for x in range(len(helyek)):
			if b + a[1] + 1 < len(helyek) and helyek[b + a[1] + 1] - helyek[b] - 1 > c:
				c = helyek[b + a[1] + 1] - helyek[b] - 1
				mo = [helyek[b], helyek[b + a[1] + 1]]
			b = b + 1
		for x in range(len(sorozat)):
			if mo[0] < x and x < mo[1]:
				sorozat[x] = 1
	print(c)
	for x in range(len(sorozat)):
		print(sorozat[x], end=' ')
main()


(n, k) = map(int, input().split())
ara = list(map(int, input().split()))
max = 0
zero = 0
value = 0
end = 0
for i in range(n):
	if ara[i] == 0:
		zero += 1
	if zero <= k:
		max += 1
		end = i
	else:
		if ara[value] == 0:
			zero -= 1
		value += 1
print(max)
for i in range(end - max + 1, end + 1):
	ara[i] = 1
ch = ''
for i in range(n):
	ch += str(ara[i]) + ' '
print(ch[:-1])


import sys
(n, k) = map(int, input().split())
a = list(map(int, sys.stdin.readline().split()))
l = 0
r = 0
zeroCount = 0
ans = 0
imax = 0
for i in range(n):
	if a[i] == 1:
		r += 1
	elif zeroCount == k:
		while a[l] != 0:
			l += 1
		l += 1
		r += 1
	else:
		zeroCount += 1
		r += 1
	if r - l > ans:
		ans = r - l
		imax = r
for i in range(imax - ans, imax):
	a[i] = 1
print(ans)
print(*a)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
ans = 0

def get(x):
	return 1 - x
l = 0
r = -1
cnt = 0
L = n
R = 0
while l < n:
	while r + 1 < n and cnt + get(s[r + 1]) <= k:
		cnt += get(s[r + 1])
		r += 1
	now = r - l + 1
	if now > ans:
		ans = now
		L = l
		R = r
	cnt -= get(s[l])
	l += 1
for i in range(L, R + 1):
	s[i] = 1
print(ans)
print(' '.join(map(str, s)))


from sys import stdin, stdout
L = list(map(int, stdin.readline().split()))
n = L[0]
k = L[1]
a = [int(c) for c in stdin.readline().split()]
nbr0 = 0
posi = 0
taillemax = 0
p = 0
for i in range(len(a)):
	nbr0 += a[i] == 0
	if nbr0 > k:
		if i - posi > taillemax:
			p = posi
			taillemax = i - posi
		j = posi
		while 1:
			if a[j] == 0:
				posi = j + 1
				break
			j = j + 1
		nbr0 -= 1
if i == n - 1 and i - posi + 1 > taillemax:
	p = posi
	taillemax = i - posi + 1
print(taillemax)
ch = ''
for i in range(len(a)):
	if i >= p and i < p + taillemax:
		ch += '1 '
	else:
		ch += str(a[i]) + ' '
stdout.write(ch)


s = list(map(int, input().split()))
s1 = list(map(int, input().split()))
start = 0
end = 0
c = 0
s2 = 0
x = 0
y = 0
while end < s[0]:
	if s1[end] == 0:
		c += 1
	while c > s[1]:
		c += s1[start] - 1
		start += 1
	if end - start + 1 > s2:
		s2 = end - start + 1
		x = start
		y = end
	end += 1
print(s2)
for i in range(x, y + 1):
	if s2 > 0:
		if s1[i] == 0:
			s1[i] = 1
			s2 -= 1
print(*s1)


import sys
f = sys.stdin.readline
(n, k) = map(int, f().strip().split())
arr = [int(v) for v in f().strip().split()]
zr = 0
i = 0
j = 0
ans = -1
ids = [0] * n
while i < n:
	while j < n and zr <= k:
		if arr[j] == 0:
			zr += 1
		j += 1
	ans = max(ans, j - i - 1) if zr > k else max(ans, j - i)
	ids[i] = ans
	if arr[i] == 0:
		zr -= 1
	i += 1
print(ans)
i = ids.index(ans)
arr = arr[:i] + [1] * ans + arr[i + ans:]
print(' '.join(map(str, arr)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
ans = -1000000000
start = 0
ss = 0
se = 0
for end in range(0, n):
	if a[end] == 0:
		c += 1
	while c > k:
		c += a[start] - 1
		start += 1
	if end - start + 1 > ans:
		ans = end - start + 1
		ss = start
		se = end
print(ans)
for i in range(ss, se + 1):
	if a[i] == 0:
		a[i] = 1
print(*a)


import math
from math import log2, sqrt
from bisect import bisect_left, bisect_right
import bisect
import sys
from sys import stdin, stdout
import os
sys.setrecursionlimit(pow(10, 7))
import collections
from collections import defaultdict
from statistics import median
from queue import Queue
inf = float('inf')
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
zeros = 0
it1 = 0
it2 = 0
maxa = 0
pointer1 = 0
pointer2 = -1
while it1 < n and it2 < n:
	if l[it2]:
		pass
	elif k > 0:
		k -= 1
	else:
		while l[it1]:
			it1 += 1
		it1 += 1
	now = it2 - it1 + 1
	if now > maxa:
		maxa = now
		pointer1 = it1
		pointer2 = it2
	it2 += 1
for i in range(pointer1, pointer2 + 1):
	l[i] = 1
print(maxa)
print(*l)


from collections import Counter

def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def printlist(l):
	print(' '.join([str(x) for x in l]))
(n, k) = mp()
a = lt()
c = 0
maxx = 0
j = 0
index = None
if k == 0:
	w = ''.join([str(x) for x in a])
	y = max([len(m) for m in w.split('0')])
	print(y)
	printlist(a)
	exit()
for i in range(n):
	if i >= 1 and a[i - 1] == 0:
		c -= 1
	while j < n and c <= k:
		if a[j] == 0:
			c += 1
		j += 1
	if c > k:
		r = j - i - 1
	else:
		r = j - i
	if r > maxx:
		maxx = r
		if c > k:
			index = (i, j - 1)
		else:
			index = (i, j)
a[index[0]:index[1]] = [1] * (index[1] - index[0])
print(maxx)
printlist(a)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = e = ans = c = ans_s = 0
ans_e = -1
while e < n:
	if not a[e]:
		c += 1
		while c > k and e >= s:
			if not a[s]:
				c -= 1
			s += 1
	if c <= k and e - s + 1 > ans_e - ans_s + 1:
		ans_s = s
		ans_e = e
	e += 1
print(ans_e - ans_s + 1)
for i in range(n):
	if i >= ans_s and i <= ans_e:
		print(1, end=' ')
	else:
		print(a[i], end=' ')


(a, k) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
zeros = 0
left = 0
right = 0
consec = 0
best = 0
switch = []
best_coords = (0, 0)
if k == 0:
	for i in range(len(arr)):
		if arr[i] == 1:
			consec += 1
			if consec > best:
				best = consec
		else:
			consec = 0
else:
	while right < len(arr):
		if arr[right] == 0 and zeros + 1 > k:
			while arr[left] == 1:
				left += 1
				consec -= 1
			zeros -= 1
			left += 1
			consec -= 1
		else:
			if arr[right] == 0:
				zeros += 1
			consec += 1
			right += 1
			if consec > best:
				best = consec
				best_coords = (left, right)
print(best)
ans = ''
for i in range(len(arr)):
	if best_coords[0] <= i < best_coords[1]:
		ans += '1 '
	else:
		ans += str(arr[i]) + ' '
print(ans)


import sys
import inspect
import re
import math
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 15

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(m, z, v, e) = (0, 0, 0, 0)
	for i in range(n):
		if a[i] == 0:
			z += 1
		if z <= k:
			m += 1
			e = i
		else:
			if a[v] == 0:
				z -= 1
			v += 1
	print(m)
	for i in range(e - m + 1, e + 1):
		a[i] = 1
	print(' '.join(map(str, a)))
main()


3
__metaclass__ = type
__author__ = 'xdlove'
(n, k) = list(map(int, input().split()))
res = [int(x) for x in input().split()]
(l, r) = (-1, -2)
(L, num_0) = (0, 0)
for R in range(n):
	if res[R] == 0:
		num_0 += 1
	while num_0 > k:
		if r - l < R - L:
			(l, r) = (L, R)
		if res[L] == 0:
			num_0 -= 1
		L += 1
	if R == n - 1 and r - l < R + 1 - L:
		(l, r) = (L, R + 1)
print(r - l)
for i in range(n):
	if l <= i < r:
		res[i] = 1
	res[i] = str(res[i])
print(' '.join(res))


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
ans = []
for i in range(len(z)):
	if z[i] == 0:
		ans.append(i)
freq = []
count = 1
inde = 0
if len(ans) == 0:
	print(len(z))
	print(*z)
	exit()
pair = [[0, 0] for i in range(len(ans))]
if z[0] == 0:
	inde = 1
for i in range(1, len(z)):
	if z[i] == z[i - 1]:
		count += 1
		if z[i] == 0:
			inde += 1
	else:
		freq.append(count)
		if z[i] == 0:
			pair[inde][0] = count
			inde += 1
		count = 1
freq.append(count)
if b == 0:
	if z[0] == 1:
		print(max(freq[0::2]))
		print(*z)
	else:
		if len(freq) == 1:
			print(0)
			print(*z)
			exit()
		print(max(freq[1::2]))
		print(*z)
	exit()
for i in range(1, len(ans)):
	pair[i - 1][1] = ans[i] - ans[i - 1] - 1
pair[-1][1] = len(z) - 1 - ans[-1]
l = 0
maxa = 0
ye = 0
inde = 0
k = b
if len(ans) <= k:
	print(len(z))
	ans = [1 for i in range(len(z))]
	print(*ans)
	exit()
for i in range(len(ans) - k + 1):
	ye = pair[i][0] + pair[i + k - 1][1] + ans[i + k - 1] - ans[i] + 1
	if ye > maxa:
		maxa = ye
		inde = i
for i in range(ans[inde], len(z)):
	if z[i] == 0:
		z[i] = 1
		k -= 1
	if k == 0:
		break
print(maxa)
print(*z)


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
(s, ii, ans) = (0, 0, 0)
(a1, a2) = (-1, -1)
for i in range(n):
	if arr[i] == 0:
		s += 1
	if s > k:
		if arr[ii] == 0:
			s = s - 1
		ii += 1
	if ans < i - ii + 1:
		ans = i - ii + 1
		a1 = ii
		a2 = i
print(ans)
for i in range(n):
	if i >= a1 and i <= a2:
		print(1, end=' ')
	else:
		print(arr[i], end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 0
ans = 0
ans_pr = [0, 0]
ct = 0
while l < n:
	while r < n and (a[r] or ct < k):
		ct += not a[r]
		r += 1
	if r - l > ans:
		ans = r - l
		ans_pr = [l, r]
	ct -= not a[l]
	l += 1
print(ans)
print(*a[:ans_pr[0]] + [1] * ans + a[ans_pr[1]:])


class MaxSum(object):

	def __init__(self, init_list):
		self.l = init_list
		self.subl = []

	def max_sum(self):
		sum = 0
		ans = 0
		if max(self.l) < 0:
			return 0
		for x in self.l:
			sum += x
			ans = sum if sum > ans else ans
			if sum < 0:
				sum = 0
		return ans
(n, k) = map(int, input().split())
lk = list(map(int, input().split()))
l1 = [1 - i for i in lk]
l = r = lm = lr = 0
su = l1[0]
ma = 1
ind = 1
if k > 0:
	while su <= k:
		if ind == n:
			break
		if su + l1[ind] <= k:
			r += 1
			su += l1[ind]
			ma += 1
			ind += 1
		else:
			break
	rm = r
	while r + 1 < n:
		while l1[l] == 0:
			l += 1
		l += 1
		r += 1
		if r == n - 1:
			if r + 1 - l > ma:
				ma = r + 1 - l
				lm = l
				rm = r
			break
		while l1[r + 1] == 0:
			r += 1
			if r == n - 1:
				break
		if r + 1 - l > ma:
			ma = r + 1 - l
			lm = l
			rm = r
	print(ma)
else:
	print(MaxSum([-n if i == 0 else 1 for i in lk]).max_sum())
if k == 0:
	print(*lk)
else:
	for i in range(lm, rm + 1):
		lk[i] = 1
	print(*lk)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
(i, j, l) = (0, -1, 0)
(z1, z2) = (0, -1)
while i < n and j < n:
	if l <= k:
		if j - i + 1 > z2 - z1 + 1:
			(z1, z2) = (i, j)
		j += 1
		if j < n:
			l += 1 - a[j]
		else:
			break
	else:
		l -= 1 - a[i]
		i += 1
print(z2 - z1 + 1)
for i in range(z1, z2 + 1):
	a[i] = 1
print(*a)


from sys import stdin

def main():
	(n, k) = map(int, stdin.readline().split())
	ar = list(map(int, stdin.readline().split()))
	start = 0
	end = -1
	zeros = 0
	ans = 0
	sid = -1
	eid = -2
	while end < n:
		while end < n and zeros <= k:
			end += 1
			if end < n and ar[end] == 0:
				zeros += 1
		if ans < end - start:
			ans = end - start
			sid = start
			eid = end - 1
		while start <= end and zeros > k:
			if ar[start] == 0:
				zeros -= 1
			start += 1
	for i in range(sid, eid + 1):
		ar[i] = 1
	print(ans)
	print(*ar)
main()


import random
from collections import Counter, namedtuple
Array = namedtuple('Array', ['length', 'start', 'stop'])

def get_solution(n, k, input_list):
	array = Array(0, 0, 0)
	stop = 0
	zeros = 0
	for start in range(n):
		while stop < n:
			value = input_list[stop]
			length = stop - start + 1
			if value == 0:
				zeros += 1
			if zeros > k and value == 0:
				zeros -= 1
				break
			else:
				if array.length < length:
					array = Array(length, start, stop + 1)
				stop += 1
		if input_list[start] == 0:
			zeros -= 1
		start += 1
	return array

def solve(n, k, input_list):
	solution = get_solution(n, k, input_list)
	if solution:
		(length, start, stop) = solution
		input_list[start:stop] = [1] * (stop - start)
		print(length)
	else:
		print(0)
	print(' '.join(map(str, input_list)))

def main():
	(n, k) = map(int, input().split())
	input_list = list(map(int, input().split()))
	solve(n, k, input_list)
main()


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
s = input().split()
a = []
for x in s:
	a.append(int(x))
(L, R) = ([], [])
for i in range(n + 2):
	L.append(0)
	R.append(0)
for i in range(1, n + 1):
	if a[i - 1] == 1:
		L[i] = L[i - 1] + 1
for i in range(n, 0, -1):
	if a[i - 1] == 1:
		R[i] = R[i + 1] + 1
zeros = []
for i in range(n + 2):
	zeros.append(0)
c = 0
for i in range(1, n + 1):
	c += a[i - 1] == 0
	zeros[i] = c
z = 0
(l, r) = (0, k + 1)
(left, right) = (-1, -1)
while l <= r and r <= n + 1:
	t = zeros[r - 1] - zeros[l]
	if t > k:
		l += 1
	else:
		x = L[l] + R[r] + (r - l - 1)
		if x > z:
			z = x
			(left, right) = (l + 1, r - 1)
		r += 1
print(z)
for i in range(n):
	if i + 1 >= left and i + 1 <= right:
		print('1', end=' ')
	else:
		print(a[i], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ki = 1
p0 = 0
i = 0
s = 0
for j in range(n):
	if l[j] == 0:
		s += 1
	while s > k:
		if l[i] == 0:
			s -= 1
		i += 1
	if j - i > p0 - ki:
		p0 = j
		ki = i
print(p0 - ki + 1)
for h in range(ki, p0 + 1):
	l[h] = 1
print(*l, sep=' ')


def main():
	(n, k) = list(map(int, input().split()))
	nums = input().split()
	nums.append('0')
	n += 1
	maxr = maxi = front = rear = 0
	while front < n:
		for front in range(front, n):
			if nums[front] == '0':
				if k > 0:
					k -= 1
				else:
					break
		r = front - rear
		if r > maxr:
			maxr = r
			maxi = rear
		if nums[rear] == '0':
			if front > rear:
				k += 1
			else:
				front += 1
		rear += 1
	nums.pop()
	nums[maxi:maxi + maxr] = ('1' for _ in range(maxr))
	print(maxr)
	print(' '.join(nums))
main()


import sys
from collections import defaultdict as dd
pl = 1
from math import *
import copy
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
d = []
from bisect import *
from itertools import permutations
from collections import deque

def siv(n):
	prime = [True for i in range(n + 1)]
	p = 2
	if 1:
		while p * p <= n:
			if prime[p] == True:
				for i in range(p * p, n + 1, p):
					prime[i] = False
			p += 1
		for p in range(2, n + 1):
			if prime[p]:
				d.append(p)
(n, k) = mi()
a = li()

def can(mid):
	mini = n
	l = r = zero = 0
	while r <= n and l <= r:
		if r - l == mid:
			mini = min(mini, zero)
			if a[l] == 0:
				zero -= 1
			l += 1
		if l == n or r == n:
			break
		if a[r] == 0:
			zero += 1
		r += 1
	return mini <= k
l = 0
r = n
ans = n
while l <= r:
	mid = (l + r) // 2
	if can(mid):
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
mini = n
p = [0, n]
l = r = zero = 0
while r <= n and l <= r:
	if r - l == ans:
		if zero < mini:
			p = [l, r]
		mini = min(mini, zero)
		if a[l] == 0:
			zero -= 1
		l += 1
	if l == n or r == n:
		break
	if a[r] == 0:
		zero += 1
	r += 1
for i in range(p[0], p[1]):
	a[i] = 1
print(ans)
print(*a)


import bisect

def readline():
	return [int(x) for x in input().strip().split()]

def to_s(iterable):
	return (str(obj) for obj in iterable)

class Solver:

	def __init__(self):
		self.n = None
		self.k = None
		self.a = None
		self.sums = []

	def main(self):
		(self.n, self.k) = readline()
		self.a = [0] + readline()
		self.sums.append(0)
		for val in self.a[1:]:
			self.sums.append(self.sums[-1] + (val == 0))
		(best_start, best_end) = (0, -1)
		for i in range(1, self.n + 1):
			end = bisect.bisect_right(self.sums, self.k + self.sums[i - 1], i)
			if end - i > best_end - best_start:
				(best_start, best_end) = (i, end)
		print(best_end - best_start)
		for i in range(best_start, best_end):
			self.a[i] = 1
		print(' '.join(to_s(self.a[1:])))
Solver().main()


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
zer = [0] * (n + 1)
for i in range(n):
	if lis[i] == 0:
		zer[i + 1] = zer[i] + 1
	else:
		zer[i + 1] = zer[i]
ind = ans = 0
for i in range(n):
	l = i + 1
	r = n
	while l <= r:
		mid = l + (r - l) // 2
		ze = zer[mid] - zer[i]
		if ze > k:
			r = mid - 1
		else:
			l = mid + 1
	if zer[r] - zer[i] <= k and r - i > ans:
		ans = r - i
		ind = i
i = ind
while i < n and k:
	if lis[i] == 0:
		lis[i] = 1
		k -= 1
	i += 1
print(ans)
print(*lis)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ki = i = s = 0
po = 1
for j in range(n):
	if a[j] == 0:
		s += 1
	while s > k:
		if a[i] == 0:
			s -= 1
		i += 1
	if j - i > ki - po:
		po = i
		ki = j
print(ki - po + 1)
a[po:ki + 1] = [1] * (ki - po + 1)
print(*a)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	i = j = start = end = ans = cur = cnt = 0
	for i in range(n):
		if a[i] == 0:
			cnt += 1
		while cnt > k:
			if a[j] == 0:
				cnt -= 1
			j += 1
		cur = i - j + 1
		if cur > ans:
			start = j
			end = i
			ans = cur
	if k:
		for i in range(start, end + 1):
			a[i] = 1
	print(ans)
	print(*a)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
i = 0
j = 0
Ansp = [0, 0]
zcnt = 0
max = 0
while i <= n - 1:
	while j < n:
		if zcnt >= k and a[j] == 0:
			break
		j += 1
		if not a[j - 1]:
			zcnt += 1
			if zcnt > k:
				j -= 1
				zcnt -= 1
				break
	l = j - i
	if l > max:
		max = l
		Ansp = [i, j]
	if not a[i]:
		zcnt -= 1
	i += 1
for i in range(Ansp[0], Ansp[1]):
	a[i] = 1
print(max)
print(' '.join(map(str, a)))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
m = 0
z = 0
p = 0
r = 0
for i in range(n):
	if l[i] == 0:
		z += 1
	if z <= k:
		m += 1
		r = i
	else:
		if l[p] == 0:
			z -= 1
		p += 1
print(m)
l[r - m + 1:r + 1] = [1] * m
print(*l)


mx = 0

def f(need, c, k, n):
	for i in range(n):
		if i + need - 1 >= n:
			break
		temp = c[i + need - 1]
		if i > 0:
			temp -= c[i - 1]
		if temp + k >= need:
			return (True, i)
	return (False, None)

def main():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = [0 for i in range(n)]
	c[0] = a[0]
	for i in range(1, n):
		c[i] = c[i - 1]
		if a[i] == 1:
			c[i] += 1
	(l, r) = (k, n + 1)
	while r - l > 100:
		m = (l + r) // 2
		if f(m, c, k, n)[0]:
			l = m
		else:
			r = m
	for i in range(r, l - 1, -1):
		(res, start) = f(i, c, k, n)
		if res:
			print('%d' % i)
			print(' '.join((str(x) for x in a[:start] + [1] * i + a[start + i:])))
			return

def __starting_point():
	main()
__starting_point()


(n, k) = list(map(int, input().split()))
m = list(map(int, input().split()))
ls = [0]
now = 0
for i in range(n):
	now += m[i]
	ls += [now]
s = 1
bz = 0
locs = [0, 0]
for i in range(1, n + 1):
	su = ls[i] - ls[s - 1]
	t = i - s + 1
	if t - su <= k:
		if bz < t:
			bz = t
			locs = [s, i]
	else:
		t = i - s + 1
		su = ls[i] - ls[s - 1]
		while t - su > k:
			s += 1
			t = i - s + 1
			su = ls[i] - ls[s - 1]
m[locs[0] - 1:locs[1]] = [1] * bz
print(bz)
print(*m)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
b = [0, 0]
t = 0
tt = n
o = []
temp = 0
s = []
for i in range(n):
	temp += a[i]
	s.append(temp)
	o.append(tt)
	if a[n - i - 1] == 0:
		tt = n - i - 1
o.reverse()
l = 0
r = -1
for i in range(n):
	if a[i] == 1:
		b[a[i]] += 1
	elif b[0] < k:
		b[0] += 1
	elif a[t] == 0:
		t += 1
	else:
		temp = 1 + s[o[t]] - s[t]
		b[1] -= temp
		t = o[t] + 1
	if ans < b[0] + b[1]:
		l = t
		r = i
		ans = b[0] + b[1]
for i in range(l, r + 1):
	a[i] = 1
print(ans)
print(*a)


L = list(map(int, input().split()))
n = L[0]
k = L[1]
a = list(map(int, input().split()))
nbr0 = 0
posi = 0
taillemax = 0
p = 0
for i in range(len(a)):
	nbr0 += a[i] == 0
	if nbr0 > k:
		if i - posi > taillemax:
			p = posi
			taillemax = i - posi
		j = posi
		while 1:
			if a[j] == 0:
				posi = j + 1
				break
			j = j + 1
		nbr0 -= 1
if i == n - 1 and i - posi + 1 > taillemax:
	p = posi
	taillemax = i - posi + 1
print(taillemax)
ch = ''
for i in range(len(a)):
	if i >= p and i < p + taillemax:
		ch += '1 '
	else:
		ch += str(a[i]) + ' '
print(ch)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
PI = float('inf')

def fn(wl, st):
	l = 0
	r = wl - 1
	mn = PI
	p1 = p2 = -1
	while r < n:
		zeros = ps[r] - (ps[l - 1] if l >= 1 else 0)
		if zeros <= k and zeros < mn:
			mn = zeros
			(p1, p2) = (l, r)
		l += 1
		r += 1
	if mn == PI:
		return False
	if st:
		for i in range(p1, p2 + 1):
			a[i] = 1
	return True
for _ in range(1):
	(n, k) = lst()
	ps = [0] * n
	a = lst()
	for i in range(n):
		if a[i] == 0:
			ps[i] = ps[max(0, i - 1)] + 1
		else:
			ps[i] = ps[max(0, i - 1)]
	l = 1
	r = n + 1
	while l <= r:
		mid = l + r >> 1
		if fn(mid, 0):
			l = mid + 1
		else:
			r = mid - 1
	print(r)
	fn(r, 1)
	print(*a)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
ans = 0
ansL = -1
ansR = -1
c0 = 0
l = 0
r = 0
while r < n:
	if a[r] == 0:
		c0 += 1
	while l <= r and c0 > k:
		c0 -= a[l] == 0
		l += 1
	if ans < r - l + 1 and c0 <= k:
		ansL = l
		ansR = r
		ans = r - l + 1
	r += 1
print(ans)
for i in range(n):
	if i >= ansL and i <= ansR:
		a[i] = 1
print(*a)


import bisect
(n, k) = map(int, input().split())
v = list(map(int, input().split()))
prefix = [0 for _ in range(n + 1)]
suff = [0 for _ in range(n + 1)]
pref = [0 for _ in range(n + 1)]
zero = [0 for _ in range(n + 1)]
for i in range(0, n):
	if v[i] == 0:
		zero[i + 1] = 1 + zero[i]
		prefix[i + 1] = prefix[i]
	else:
		zero[i + 1] = zero[i]
		prefix[i + 1] = 1 + prefix[i]
for i in range(0, n):
	if v[i] == 1:
		pref[i + 1] = 1 + pref[i]
for i in range(n - 1, -1, -1):
	if v[i] == 1:
		suff[i] = 1 + suff[i + 1]
l = r = -1
mxm = max(pref)
if k == 0:
	print(max(pref))
	print(*v)
	exit()
for i in range(0, n):
	if v[i] == 0:
		index = bisect.bisect_left(zero, k + zero[i], 0, n + 1)
		if index >= n + 1:
			index -= 1
		x = y = z = 0
		x = pref[i]
		y = prefix[index] - prefix[i]
		if index < n + 1:
			z = suff[index]
		sum = zero[index] - zero[i] + x + y + z
		if mxm < sum:
			mxm = sum
			l = i
			r = index - 1
for i in range(l, r + 1):
	if v[i] == 0:
		v[i] = 1
print(mxm)
print(*v)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
cnt = i = sm = 0
pos = 1
for j in range(n):
	sm += l[j] == 0
	while sm > k:
		sm -= l[i] == 0
		i += 1
	if j - i > cnt - pos:
		(pos, cnt) = (i, j)
print(cnt - pos + 1)
l[pos:cnt + 1] = [1] * (cnt - pos + 1)
print(' '.join(map(str, l)))


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd
(n, k) = mp()
l = mp()
(i, j, count) = (0, 0, 0)
temp = 0
v = [0, -1]
while i < n and j < n:
	if count <= k:
		if l[i] == 0:
			count += 1
		i += 1
	else:
		if l[j] == 0:
			count -= 1
		j += 1
	if count <= k:
		if abs(i - j) > temp:
			temp = max(temp, abs(i - j))
			v = [j, i]
print(temp)
for i in range(v[0], v[1]):
	l[i] = 1
print(*l)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime
fans = []

def good(mid, p, k):
	i = 1
	j = mid
	f = 0
	while j < len(p):
		zero = mid - (p[j] - p[i - 1])
		if zero <= k:
			fans.clear()
			fans.append([i, j])
			return True
		i += 1
		j += 1
	return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
p = [0] + list(accumulate(a))
l = 0
r = n + 1
ans = 0
while l <= r:
	mid = (l + r) // 2
	if good(mid, p, k) == True:
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
print(ans)
i = fans[0][0]
j = fans[0][1]
for k in range(i - 1, j):
	a[k] = 1
print(*a)


import sys
(n, k) = map(int, sys.stdin.buffer.readline().split())
a = [0] + list(map(int, sys.stdin.buffer.readline().split()))
zero = [0] * (n + 1)
for i in range(1, n + 1):
	zero[i] = zero[i - 1] + (1 if a[i] == 0 else 0)

def solve(x):
	for i in range(x, n + 1):
		if zero[i] - zero[i - x] <= k:
			return i
	return -1
(ok, ng) = (0, n + 1)
while abs(ok - ng) > 1:
	mid = ok + ng >> 1
	if solve(mid) != -1:
		ok = mid
	else:
		ng = mid
r = solve(ok)
a[r - ok + 1:r + 1] = [1] * ok
sys.stdout.buffer.write((str(ok) + '\n' + ' '.join(map(str, a[1:]))).encode('utf-8'))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (0, 0)
(ans_idx, ans_len) = (0, 0)
zeros = 0
while r < n:
	if r < n:
		zeros += a[r] == 0
		r += 1
	if zeros > k:
		zeros -= a[l] == 0
		l += 1
	if r - l > ans_len:
		ans_len = r - l
		ans_idx = l
print(ans_len)
zeros = 0
for i in range(n):
	if i < ans_idx:
		print(a[i], end=' ')
	elif i >= ans_idx and zeros < k:
		zeros += a[i] == 0
		print(1, end=' ')
	else:
		print(a[i], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ki = i = s = 0
po = 1
for j in range(n):
	s += l[j] == 0
	while s > k:
		s -= l[i] == 0
		i += 1
	if j - i > ki - po:
		(po, ki) = (i, j)
print(ki - po + 1)
l[po:ki + 1] = [1] * (ki - po + 1)
print(' '.join(map(str, l)))


import sys
import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = [1000000.0] * int(300000.0 + 1)
(pos, ans, res) = (0, 0, 0)
for i in range(n):
	ans += a[i] == 0
	d[ans] = min(d[ans], i)
	d[0] = -1
	cc = d[ans - k if ans - k >= 0 else 0]
	if res < i - cc:
		pos = cc + 1
		res = i - cc
print(res)
a[pos:pos + res] = [1] * res
print(*a)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
(bl, br, bv) = (-1, -1, 0)
l = 0
c = 0
r = 0
while r < n:
	if a[r] == 0:
		if c < k:
			c += 1
		else:
			if r - l > bv:
				bv = r - l
				bl = l
				br = r
			while a[l] == 1:
				l += 1
			l += 1
	r += 1
if r - l > bv:
	bv = r - l
	bl = l
	br = r
print(bv)
for i in range(n):
	if i >= bl and i < br:
		print(1, end=' ')
	else:
		print(a[i], end=' ')


from collections import defaultdict

def put():
	return map(int, input().split())
(n, k) = put()
l = list(put())
if sum(l) + k >= n:
	print(n)
	print('1 ' * n)
	exit()
(left, right, ind) = ([0] * n, [0] * n, [])
prev = 0
for i in range(n):
	if l[i]:
		prev += 1
		left[i] = prev
	else:
		prev = 0
if k == 0:
	print(max(left))
	print(*l)
	exit()
prev = 0
for i in range(n - 1, -1, -1):
	if l[i]:
		prev += 1
		right[i] = prev
	else:
		prev = 0
for i in range(n):
	if not l[i]:
		ind.append(i)
index = -1
ans = 0
(i, j) = (0, k - 1)
leng = len(ind)
while j < leng:
	start = ind[i]
	end = ind[j]
	x = 0 if start - 1 < 0 else left[start - 1]
	y = 0 if end + 1 >= n else right[end + 1]
	z = x + end - start + 1 + y
	if ans < z:
		index = i
		ans = z
	(i, j) = (i + 1, j + 1)
print(ans)
for i in range(k):
	l[ind[index + i]] = 1
print(*l)


import sys
input = sys.stdin.readline

def prog():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split())) + [0]
	count = 0
	for i in range(n):
		if a[i] == 1:
			count += 1
	if count + k >= n:
		print(n)
		print('1 ' * n)
	elif k == 0:
		last = 0
		mx = 0
		for i in range(n):
			if a[i] == 1 and a[i + 1] == 0:
				mx = max(mx, i - last + 1)
			if a[i] == 0 and a[i + 1] == 1:
				last = i + 1
		print(mx)
		a.pop()
		print(*a)
	else:
		zero_locs = []
		for i in range(n):
			if a[i] == 0:
				zero_locs.append(i)
		suffix = [0] * (n + 2)
		prefix = [0] * (n + 2)
		last = 0
		for i in range(n):
			if a[i] == 1 and a[i + 1] == 0:
				suffix[i + 1] = i - last + 1
				prefix[last + 1] = i - last + 1
			if a[i] == 0 and a[i + 1] == 1:
				last = i + 1
		mx = 0
		best = k - 1
		for r in range(k - 1, len(zero_locs)):
			amt = zero_locs[r] - zero_locs[r - (k - 1)] + 1 + suffix[zero_locs[r - (k - 1)]] + prefix[zero_locs[r] + 2]
			if amt > mx:
				mx = amt
				best = r
		a.pop()
		for i in range(zero_locs[best - (k - 1)], zero_locs[best] + 1):
			a[i] = 1
		print(mx)
		print(*a)
prog()


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
(n, k) = ris()
a = ris()
ri = rj = i = m = 0
for j in range(n):
	if a[j] == 0:
		m += 1
		while k < m:
			if a[i] == 0:
				m -= 1
			i += 1
	if rj - ri <= j - i:
		(ri, rj) = (i, j + 1)
for i in range(ri, rj):
	a[i] = 1
print(rj - ri)
print(*a)


from bisect import bisect_left, bisect_right
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
sum_arr = []
count = 0
for i in range(n):
	if arr[i] == 0:
		count += 1
	sum_arr.append(count)
maxi = 0
(l, r) = (0, 0)
extra = 0
for i in range(n):
	extra = (arr[i] + 1) % 2
	indx = bisect_right(sum_arr, sum_arr[i] + k - extra)
	if indx - i > maxi:
		l = i
		r = indx
		maxi = indx - i
if maxi == 0:
	(l, r) = (0, k)
	maxi = k
for i in range(l, r):
	arr[i] = 1
print(maxi)
print(*arr)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
if 0 not in a:
	print(n)
	print(*a)
	exit()
if 1 not in a:
	print(k)
	res = [1] * k + [0] * (n - k)
	print(*res)
	exit()
zeroes = []
max_ones = 0
ones = 0
for i in range(n):
	if a[i] == 0:
		zeroes.append(i)
		max_ones = max(max_ones, ones)
		ones = 0
	else:
		ones += 1
max_ones = max(max_ones, ones)
if k == 0:
	print(max_ones)
	print(*a)
	exit()
if len(zeroes) <= k:
	print(n)
	res = [1] * n
	print(*res)
	exit()
first = 0
last = k - 1
res = 0
res_first = 0
while last < len(zeroes):
	before = zeroes[first] - zeroes[first - 1] - 1 if first > 0 else zeroes[first]
	after = zeroes[last + 1] - zeroes[last] - 1 if last < len(zeroes) - 1 else n - zeroes[last] - 1
	cnt = zeroes[last] - zeroes[first] + 1 + after + before
	if cnt > res:
		res = cnt
		res_first = zeroes[first] - before
	last += 1
	first += 1
print(res)
ans = a[0:res_first] + [1] * res + a[res_first + res:]
print(*ans)


(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
pref = [0]
for i in range(n):
	pref.append(pref[-1] + arr[i])

def sat(low, ind):
	global k
	return pref[ind + 1] - pref[low] >= ind - low + 1 - k

def bs(lo, hi):
	ret = -1
	low = lo
	while lo <= hi:
		mid = (lo + hi) // 2
		if sat(low, mid):
			ret = max(ret, mid)
			lo = mid + 1
		else:
			hi = mid - 1
	return ret
ans = 0
start = 0
for i in range(n):
	length = bs(i, n - 1) - i + 1
	if length > ans:
		ans = length
		start = i
print(ans)
for i in range(start, start + ans):
	arr[i] = 1
print(*arr)


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)

def hnbhai():
	(n, k) = sd()
	a = sd()
	start = 0
	end = 0
	length = 0
	cc = 0
	last = 0
	for i in range(n):
		if a[i] == 0:
			cc += 1
		if cc <= k:
			length += 1
			end = i
		else:
			if a[last] == 0:
				cc -= 1
			last += 1
	for i in range(end - length + 1, end + 1):
		a[i] = 1
	print(length)
	print(*a)
for _ in range(1):
	hnbhai()


from sys import stdin, stdout
import math

def main():
	line = stdin.readline()
	n = int(line.split()[0])
	k = int(line.split()[1])
	line = stdin.readline()
	arr = [int(x) for x in line.split()]
	zero = []
	j = -1
	start = 0
	zeros = 0
	ones = 0
	max_len = 0
	for i in range(n):
		if arr[i] == 1:
			ones += 1
		else:
			zero.append(i)
			if zeros < k:
				ones += 1
				zeros += 1
			else:
				j += 1
				ones = i - zero[j]
		if ones > max_len:
			start = i + 1 - ones
			max_len = ones
	print(str(max_len))
	for i in range(n):
		if i >= start and i < start + max_len:
			stdout.write(str('1 '))
		else:
			stdout.write(str(arr[i]) + ' ')
main()


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
i = 0
j = 0
c = 0
an = 0
p = [0, n - 1]
while j < n and c < k:
	if a[j] == 0:
		c += 1
	j += 1
an = j - i
p = [i, j]
while j < n:
	if a[j] == 0:
		while a[i] != 0:
			i += 1
		i += 1
	j += 1
	if j - i > an:
		an = j - i
		p = [i, j]
print(an)
print(*a[:p[0]] + ['1'] * an + a[p[1]:])


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0, -1]
(i, j) = (0, 0)
count = 0
a = 0
while i < n and j < n:
	if count <= k:
		if l[i] == 0:
			count += 1
			i += 1
		else:
			i += 1
	elif l[j] == 0:
		count -= 1
		j += 1
	else:
		j += 1
	if count <= k:
		if abs(i - j) > a:
			ans = [j, i]
			a = max(a, abs(i - j))
print(a)
for i in range(ans[0], ans[1]):
	l[i] = 1
print(*l)


import bisect
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c0 = [0] * n
if a[0] == 0:
	c0[0] += 1
for i in range(1, n):
	c0[i] += c0[i - 1]
	if a[i] == 0:
		c0[i] += 1
ans = 0
idx = 0
for i in range(n):
	if k >= c0[i]:
		if ans < i + 1:
			ans = i + 1
			idx = 0
	else:
		l = bisect.bisect_left(c0, c0[i] - k) + 1
		if ans < i - l + 1:
			idx = l
			ans = i - l + 1
arr = []
for i in range(idx):
	arr.append(a[i])
for i in range(idx, idx + ans):
	arr.append(1)
for i in range(idx + ans, n):
	arr.append(a[i])
print(ans)
print(*arr)


import sys
(n, k) = [int(a) for a in input().split()]
As = [int(a) for a in input().split()]
groupstart = [0] * n
for i in range(1, n):
	if As[i - 1] == As[i]:
		groupstart[i] = groupstart[i - 1]
	else:
		groupstart[i] = i
groupend = [n] * n
for i in range(n - 2, -1, -1):
	if As[i] == As[i + 1]:
		groupend[i] = groupend[i + 1]
	else:
		groupend[i] = i + 1

def nochange():
	print(max([0] + [groupend[i] - groupstart[i] for i in range(n) if As[i] == 1]))
	print(' '.join([str(a) for a in As]))
	sys.exit()

def allones():
	print(n)
	print(' '.join(['1' for a in As]))
	sys.exit()
if k == 0:
	nochange()
low = 0
try:
	low = As.index(0)
except ValueError:
	allones()
high = low
j = 0
while j < k:
	if As[high] == 0:
		j += 1
	high += 1
	if high == n:
		allones()
best = 0
bestlow = low
besthigh = high
while high <= n:
	fa = low if low == 0 or As[low - 1] == 0 else groupstart[low - 1]
	fb = high if high == n or As[high] == 0 else groupend[high]
	f = fb - fa
	if best < f:
		best = f
		bestlow = low
		besthigh = high
	if high == n:
		break
	low += 1
	if As[low] == 1:
		low = groupend[low]
	if As[high] == 1:
		high = groupend[high]
	high += 1
print(best)
for i in range(bestlow, besthigh):
	As[i] = 1
print(' '.join([str(a) for a in As]))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = []
for i in range(n):
	if a[i] == 0:
		s.append(i)
z = 0
c = 0
(x, w) = (0, 0)
for i in range(len(s) - k):
	y = s[i + k] - z
	if c < y:
		c = y
		x = z
		w = s[i + k]
	z = s[i] + 1
y = n - z
if c < y:
	c = y
	x = z
	w = n
for i in range(x, w):
	if a[i] == 0:
		a[i] = 1
print(c)
for i in range(n):
	print(a[i], end=' ')
print()


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))

def sortByFirstAndSecond(A):
	A = sorted(A, key=lambda x: x[0])
	A = sorted(A, key=lambda x: x[1])
	return list(A)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def check(m, a, k):
	c = a[:m].count(0)
	if c <= k:
		return 1
	for i in range(len(a)):
		if i + m >= len(a):
			break
		if a[i + m] == 0:
			c += 1
		if a[i] == 0:
			c -= 1
		if c <= k:
			return 1
	return 0

def solve():
	(n, k) = li()
	a = li()
	l = 0
	r = n
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if check(m, a, k):
			ans = m
			l = m + 1
		else:
			r = m - 1
	c = a[:ans].count(0)
	print(ans)
	if c <= k:
		res = [1] * ans + a[ans:]
		print(*res)
		return
	for i in range(len(a)):
		if i + ans >= len(a):
			break
		if a[i + ans] == 0:
			c += 1
		if a[i] == 0:
			c -= 1
		if c <= k:
			res = a[:i + 1] + [1] * ans
			x = []
			for j in range(n - 1, -1, -1):
				if len(res) + len(x) == n:
					break
				x.append(a[j])
			x.reverse()
			res += x
			print(*res)
			return
t = 1
for _ in range(t):
	solve()


(n, k) = map(int, input().split())
A = [int(x) for x in input().split()]
(a, b, c) = (0, 0, 0)
(fa, fl) = (0, 0)
while b < len(A):
	while b < len(A) and c <= k:
		if b - a > fl:
			fl = b - a
			fa = a
		if A[b] == 0:
			c += 1
		b += 1
	while c > k and a <= b:
		if A[a] == 0:
			c -= 1
		a += 1
	c = max([0, c])
	if b - a > fl:
		fl = b - a
		fa = a
print(fl)
for i in range(len(A)):
	print(1 if fa <= i and i < fa + fl else A[i], end=' ')


n = input().split()
k = int(n[-1])
n = int(n[0])
a = [int(x) for x in input().split()]
ii = 0
zero = list()
for x in a:
	if not x:
		zero.append(ii)
	ii += 1
if len(zero) - k <= 0:
	print(n)
	string = '1'
	for x in range(1, n):
		string += ' 1'
	print(string)
elif k == 0:
	string = ''
	for x in range(len(a)):
		string += str(a[x])
	o = ''
	while string.find(o + '1') != -1:
		o += '1'
	print(len(o))
	print(' '.join((str(x) for x in a)))
else:
	maxof1 = 0
	for i in range(len(zero) - k + 1):
		z = 1
		l1 = 0
		while zero[i] - z >= 0 and a[zero[i] - z]:
			l1 += 1
			z += 1
		z = 1
		l2 = 0
		while zero[i + k - 1] + z <= n - 1 and a[zero[i + k - 1] + z]:
			l2 += 1
			z += 1
		x = zero[i + k - 1] - zero[i] + 1 + l1 + l2
		if maxof1 < x:
			maxof1 = x
			maxn = i
	print(maxof1)
	for i in range(maxn, maxn + k):
		a[zero[i]] = 1
	string = str(a[0])
	for x in range(1, len(a)):
		string += ' ' + str(a[x])
	print(string)


try:
	while True:
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		left = 0
		result = -1
		cur = 0
		for i in range(n):
			if not a[i]:
				if k:
					k -= 1
				else:
					if i - left > result:
						res_left = left
						res_right = i
						result = i - left
					while left < i and a[left]:
						left += 1
					left += 1
		if i + 1 - left > result:
			res_left = left
			res_right = i + 1
			result = i + 1 - left
		print(result)
		for i in range(res_left):
			print(a[i], end=' ')
		for i in range(result):
			print(end='1 ')
		for i in range(res_right, n):
			print(a[i], end=' ')
		print()
except EOFError:
	pass