#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1, 0), c(n + 1, 0), dp(n + 1, 0);
  queue<long long> l;
  for (long long i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  if (k >= 1) {
    dp[n] = 1;
    c[n] = (a[n] != 1);
    if (c[n]) l.push(n);
  } else {
    dp[n] = (a[n] == 1);
  }
  for (long long i = n - 1; i >= 1; i--) {
    if (a[i] == 1) {
      dp[i] = 1 + dp[i + 1];
      c[i] = c[i + 1];
    } else {
      if (k == 0) {
        dp[i] = 0;
        continue;
      }
      if (c[i + 1] == k) {
        long long lt = l.front();
        l.pop();
        dp[i] = lt - i;
        l.push(i);
        c[i] = k;
      } else {
        dp[i] = dp[i + 1] + 1;
        l.push(i);
        c[i] = c[i + 1] + 1;
      }
    }
  }
  long long ma = 0, in = 0;
  for (long long i = 1; i < n + 1; i++) {
    if (dp[i] > ma) {
      ma = dp[i];
      in = i;
    }
  }
  cout << ma << '\n';
  for (long long i = 1; i < n + 1; i++) {
    if (i == in) {
      for (long long j = 0; j < ma; j++) cout << 1 << " ";
      i = i + ma - 1;
    } else
      cout << a[i] << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
