#include <bits/stdc++.h>
using namespace std;
int n, k;
int setstart;
int prefix[300001];
int exist(int length) {
  int s = 0;
  int e = length;
  while (1) {
    if (e == n + 1) return -1;
    if (length - (prefix[e] - prefix[s]) <= k) return s;
    e++, s++;
  }
}
int binary(int start, int end) {
  int mid = (start + end) / 2;
  if (exist(mid) != -1) {
    if (exist(mid + 1) == -1)
      return mid;
    else
      return binary(mid + 1, end);
  }
  return binary(start, mid - 1);
}
int main() {
  cin >> n >> k;
  int i;
  int data;
  int a[n + 1];
  prefix[0] = 0;
  for (i = 0; i < n; i++) {
    cin >> data;
    a[i] = data;
    prefix[i + 1] = prefix[i] + data;
  }
  int maxi = 0;
  maxi = binary(0, n);
  setstart = exist(maxi);
  cout << maxi << endl;
  for (i = setstart; i < setstart + maxi; i++) a[i] = 1;
  for (i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}
