#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 20;
int a[maxn], n, k;
bool ok(int len) {
  int l = 0, r = 0, z = 0;
  while (r <= n) {
    if (a[r] == 0) z++;
    if (z > k) {
      while (a[l] == 1) l++;
      l++;
      z--;
    }
    if (r - l + 1 >= len) return 1;
    r++;
  }
  return 0;
}
void pri(int ans) {
  int l = 0, r = 0, z = 0;
  while (r < n) {
    if (a[r] == 0) z++;
    if (z > k) {
      while (a[l] == 1) l++;
      l++;
      z--;
    }
    if (r - l + 1 >= ans) {
      for (int i = l; i <= r; i++) a[i] = 1;
      return;
    }
    r++;
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int l = 0, r = n, mid, t = 200, ans;
  while (t--) {
    mid = (l + r) / 2;
    if (ok(mid))
      l = mid + 1, ans = mid;
    else
      r = mid;
  }
  cout << ans << endl;
  pri(ans);
  for (int i = 0; i < n; i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
  return 0;
}
