#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const string nl = "\n";
long long n, k, ans = -INF;
vector<long long> a, hld;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n >> k;
  a.resize(n);
  hld.reserve(3e5 + 10);
  for (auto& i : a) {
    cin >> i;
  }
  for (long long i = 0; i < n; ++i) {
    if (a[i] == 0) {
      hld.push_back(i);
    }
  }
  if (k == 0) {
    long long cur = 0;
    vector<long long> hld1;
    for (long long i = 0; i < n; ++i) {
      if (a[i] == 1) {
        ++cur;
      } else {
        hld1.push_back(cur);
        cur = 0;
      }
    }
    hld1.push_back(cur);
    cout << *max_element(hld1.begin(), hld1.end()) << nl;
    for (auto& i : a) {
      cout << i << ' ';
    }
    cout << nl;
    return 0;
  }
  if (k >= ((long long)(hld).size())) {
    cout << n << nl;
    for (auto& i : a) {
      i = 1;
      cout << i << ' ';
    }
    cout << nl;
    return 0;
  }
  for (long long i = 0; i <= ((long long)(hld).size()) - k; ++i) {
    long long hld1 = 0;
    if (i == 0) {
      hld1 += hld[i];
    }
    if (i != 0 && hld[i] != 0 && hld[i - 1] != hld[i] - 1) {
      hld1 += (hld[i] - hld[i - 1]) - 1;
    }
    if (i == ((long long)(hld).size()) - k) {
      hld1 += n - hld[i + k - 1] - 1;
    }
    if (i != ((long long)(hld).size()) - k && hld[i] + k != n - 1 &&
        hld[i + k] != hld[i + k - 1] + 1) {
      hld1 += (hld[i + k] - hld[i + k - 1]) - 1;
    }
    hld1 += hld[i + k - 1] - hld[i] + 1;
    ans = max(ans, hld1);
  }
  cout << ans << nl;
  for (long long i = 0; i <= ((long long)(hld).size()) - k; ++i) {
    long long hld1 = 0;
    if (i == 0) {
      hld1 += hld[i];
    }
    if (i != 0 && hld[i] != 0 && hld[i - 1] != hld[i] - 1) {
      hld1 += (hld[i] - hld[i - 1]) - 1;
    }
    if (i == ((long long)(hld).size()) - k) {
      hld1 += n - hld[i + k - 1] - 1;
    }
    if (i != ((long long)(hld).size()) - k && hld[i] + k != n - 1 &&
        hld[i + k] != hld[i + k - 1] + 1) {
      hld1 += (hld[i + k] - hld[i + k - 1]) - 1;
    }
    hld1 += hld[i + k - 1] - hld[i] + 1;
    if (ans == hld1) {
      long long cnt = 0;
      for (long long j = hld[i]; j < n && cnt < k; ++j) {
        if (a[j] == 0) {
          ++cnt;
        }
        a[j] = 1;
      }
      for (auto& j : a) {
        cout << j << ' ';
      }
      cout << nl;
      return 0;
    }
  }
}
