#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> zero, one;
    for (int i = 0; i < n; i++) {
      if (a[i] == 0)
        zero.push_back(i);
      else
        one.push_back(i);
    }
    int l, r, l_, r_;
    int z = zero.size();
    int mx = 0, pos = -1;
    for (int i = 0; i < z; i++) {
      l = i;
      r = min(i + k - 1, z - 1);
      if (l == 0)
        l_ = -1;
      else
        l_ = zero[l - 1];
      if (r == z - 1)
        r_ = n;
      else
        r_ = zero[r + 1];
      if (mx < r_ - l_ - 1) {
        mx = r_ - l_ - 1;
        pos = zero[l];
      }
    }
    int cnt = 0;
    if (pos != -1)
      for (int i = pos; i < n; i++) {
        if (a[i] == 0 && cnt != k) {
          a[i] = 1;
          cnt++;
        }
      }
    zero.clear();
    one.clear();
    for (int i = 0; i < n; i++) {
      if (a[i] == 1)
        one.push_back(i);
      else
        zero.push_back(i);
    }
    for (int i = 0; i < one.size(); i++) {
      int l = one[i];
      int r;
      auto pos = upper_bound(zero.begin(), zero.end(), l);
      if (pos == zero.end()) {
        r = n;
      } else {
        r = zero[pos - zero.begin()];
      }
      mx = max(r - l, mx);
    }
    cout << mx << "\n";
    for (int i = 0; i < n; i++) cout << a[i] << " ";
  }
}
