#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<pair<int, int> > intervals;
vector<int> Merge;
vector<int> a;
bool valid(int from, int next) {
  int ans = Merge[next] - Merge[from];
  return ans <= k;
}
void solve() {
  int maxSize = 0, L, R;
  for (int i = 0; i < (int)intervals.size(); ++i) {
    int l = i, r = (int)intervals.size() - 1, ans = i;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (valid(i, mid)) {
        ans = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    int curSize = intervals[ans].second - intervals[i].first + 1,
        curChange = Merge[ans] - Merge[i];
    int prevZeros, nxtZeros;
    if (i) {
      prevZeros = Merge[i] - Merge[i - 1];
    } else {
      prevZeros = intervals[0].first;
    }
    if (ans == (int)intervals.size() - 1) {
      nxtZeros = n - intervals[ans].second - 1;
    } else {
      nxtZeros = Merge[ans + 1] - Merge[ans];
    }
    curSize += min(k - curChange, prevZeros + nxtZeros);
    if (curSize > maxSize) {
      maxSize = curSize;
      L = intervals[i].first - min(prevZeros, k - curChange);
      R = intervals[ans].second +
          min(nxtZeros, k - (curChange + intervals[i].first - L));
    }
  }
  while (L <= R) {
    a[L++] = 1;
  }
  printf("%d\n", maxSize);
}
int main() {
  scanf("%d%d", &n, &k);
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int l = -1, r;
  for (int i = 0; i <= n; ++i) {
    if (i == n || !a[i]) {
      if (l != -1) {
        intervals.push_back(make_pair(l, r));
        l = -1;
      }
    } else {
      if (l == -1) {
        l = r = i;
      } else {
        r++;
      }
    }
  }
  if (!intervals.size()) {
    printf("%d\n", k);
    for (int i = 0; i < k; ++i) {
      a[i] = 1;
    }
  } else {
    Merge.resize(intervals.size());
    Merge[0] = 0;
    for (int i = 1; i < (int)intervals.size(); ++i) {
      Merge[i] =
          Merge[i - 1] + (intervals[i].first - intervals[i - 1].second - 1);
    }
    solve();
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", a[i]);
  }
  return 0;
}
