#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 1000 * 100 + 10;
const long long N2 = 70;
const long double PI = 3.141592653589793;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p = LLONG_MAX) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
bool check(long long a[], long long n, long long k, long long len) {
  for (long long i = len - 1; i < n; ++i) {
    long long dum = a[i];
    if ((i - len) >= 0) dum -= a[i - len];
    dum = len - dum;
    if (dum <= k) return true;
  }
  return false;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long b[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) {
    b[i] = a[i];
  }
  for (long long i = 1; i < n; ++i) {
    a[i] += a[i - 1];
  }
  long long low = 1, high = n, ans = 0, mid;
  while (high >= low) {
    mid = (low + high) / 2;
    if (check(a, n, k, mid)) {
      low = mid + 1;
      ans = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << ans << "\n";
  for (long long i = ans - 1; i < n; ++i) {
    long long dum = a[i];
    if ((i - ans) >= 0) dum -= a[i - ans];
    dum = ans - dum;
    if (dum <= k) {
      for (long long j = i; j >= i - ans + 1; j--) {
        if (!b[j]) b[j]++;
      }
      break;
    }
  }
  for (long long i = 0; i < n; ++i) {
    cout << b[i] << " ";
  }
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  ;
  return 0;
}
