#include <bits/stdc++.h>
using namespace std;
int num[300010];
int head[300010];
int sum[300010];
int pos[300010];
int tail[300010];
int another[300010];
int fin[300010];
int sum2[300010];
int head2[300010];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", &num[i]);
  int step = 0;
  for (int i = 0; i < n; i++) {
    if (num[i] == 1) {
      if (head[step] == 0) pos[step] = i;
      if (i == 0 || num[i - 1] == 1) {
        head[step]++;
      } else {
        tail[step] = i;
        step++;
        head[step]++;
        pos[step] = i;
      }
    } else {
      sum[step]++;
      if (sum[step] <= k) head[step]++;
    }
  }
  tail[step] = n;
  int start = 0;
  for (int i = 0; i <= step; i++) {
    sum2[i] = sum[i];
    head2[i] = head[i];
  }
  while (start <= step) {
    if (sum[start] > k)
      start++;
    else {
      int temp = k - sum[start];
      fin[start] = temp;
      for (int i = tail[start]; i <= n; i++) {
        if (i != n) {
          if (num[i] == 0) temp--;
          fin[start] = temp;
        }
        if (temp < 0 || i == n) {
          if (start == step) {
            break;
          } else {
            if (i > tail[start + 1]) {
              tail[start + 1] = i;
              sum[start + 1] = k - sum2[start];
              head[start + 1] = another[start] + head[start] - head2[start];
            }
            break;
          }
        }
        another[start]++;
      }
      start++;
    }
  }
  int maxn = 0;
  int pos1 = 0;
  for (int i = 0; i <= step; i++) {
    if (fin[i] > 0) {
      int temp2 = pos[i];
      pos[i] -= fin[i];
      if (pos[i] < 0) {
        pos[i] = 0;
        head[i] += temp2;
      } else
        head[i] += fin[i];
    }
    if (head[i] + another[i] > maxn) {
      maxn = head[i] + another[i];
      pos1 = pos[i];
    }
  }
  cout << maxn << endl;
  for (int i = 0; i < pos1; i++) printf("%d ", num[i]);
  for (int i = pos1; i < n; i++) {
    if (num[i] == 0) {
      if (k) {
        printf("1 ");
        k--;
      } else
        printf("0 ");
    } else
      printf("1 ");
  }
  cout << endl;
  return 0;
}
