#include <bits/stdc++.h>
using namespace std;
void help() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int arr[300005], n, k, l1, r1;
vector<int> v;
bool check(int mid) {
  int l = 0, r = mid;
  int maxi = 0;
  while (r <= n) {
    if (l == 0) {
      maxi = arr[r - 1];
      int z = r - l;
      z -= maxi;
      if (z <= k) {
        l1 = l;
        r1 = r;
        return 1;
      }
    } else {
      maxi = arr[r - 1] - arr[r - 1 - mid];
      int z = r - l;
      z -= maxi;
      if (z <= k) {
        l1 = l;
        r1 = r;
        return 1;
      }
    }
    l++;
    r++;
  }
  return 0;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    v.push_back(arr[i]);
  }
  for (int i = 1; i < n; i++) arr[i] += arr[i - 1];
  int st = 0, en = n + 1, mid;
  while (st < en) {
    mid = (st + en + 1) / 2;
    if (check(mid))
      st = mid;
    else
      en = mid - 1;
  }
  for (int i = l1; i < r1; i++) v[i] = 1;
  cout << st << endl << v[0];
  for (int i = 1; i < v.size(); i++) cout << " " << v[i];
  cout << endl;
  return 0;
}
