#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N, K;
string S;

// See http://hos.ac/slides/20140319_bit.pdf
template<typename T>
class BIT {
  vector<T> data; // 0-indexed: 0 to N (inclusive)

public:
  explicit BIT(int n)
  {
    data.resize(n+1);
  }

  // O(N log(N))
  explicit BIT(const vector<T>& v)
  {
    data.resize(v.size()+1);
    for (int i=0; i<int(v.size()); i++) {
      add(i, v[i]);
    }
  }

  // Add x at index (0-indexed) in O(log(N))
  void add(int index, const T x) {
    for (int i=index; i<int(data.size()); i |= i+1) {
      data[i] += x;
    }
  }

  // Return a sum of [0, index) in O(log(N))
  T sum(int index) {
    T ret = 0;
    for (int i=index-1; i>=0; i=(i&(i+1))-1) {
      ret += data[i];
    }
    return ret;
  }

  // Return a sum of [s, e) in O(log(N))
  T sum(int s, int e) {
    return sum(e) - sum(s);
  }

  void dump() {
    dumpContents(data);
  }
};

int main(int argc, char** argv) {
  cin >> N >> K;
  cin >> S;

  BIT<int> bit(N+1);

  for (int i=1; i<N; i++) {
    if (S[i-1] == S[i]) continue;

    if (S[i-1] == '0') { // 01
      bit.add(i-1, 1);
    } else {
      bit.add(i, 1); //10
    }
  }
  if (S[0]   == '0') bit.add(0,  1);
  if (S[N-1] == '0') bit.add(N-1,1);

  // [i, j)
  int i=0;
  int j=1;
  int ret = 0;
  while (i<j && j<=N) {
    if (j!=N && S[j-1] == '0') {
      j++;
      continue;
    }

    int curK = bit.sum(i, j);
    //cerr << "i,j: " << i << "," << j << "  curK: " << curK << endl;
    if (curK > 2*K) {
      i++;
      continue;
    }

    chmax(ret, j-i);
    //cerr << "i,j: " << i << "," << j << "  ret: " << ret << " (" << curK << ")" << endl;
    j++;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 848