#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans, a[300020];
  while (~scanf("%d%d", &n, &k)) {
    int l = 0, a1 = 0, a0 = 0, ans = 0;
    int ll, rr;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 1)
        a1++;
      else
        a0++;
      if (a0 > k) {
        if (a[++l] == 0)
          a0--;
        else
          a1--;
      }
      if (a0 + a1 > ans) {
        ans = a0 + a1;
        ll = l + 1;
        rr = i;
      }
    }
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++) {
      if (i >= ll && i <= rr)
        printf("1 ");
      else
        printf("%d ", a[i]);
    }
    printf("\n");
  }
  return 0;
}
