#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

class zeroblock{
	public:
		int l, r, len, lenex, index, done;
		int lpos, rpos;
		zeroblock* phead;
		zeroblock* pnext;
		zeroblock* pprev;
		zeroblock* plast;
		zeroblock(){
			l = 0;     // 左にある1の連続長さ
			r = 0;     // 右にある1の連続長さ
			len = 0;   // 自分の0の長さ
			lenex = 0; // l + r + len
			index = 0; // Bの中でのindex
			done  = 0; //逆立ちさせたかどうか
			lpos  = -1; //lenexすべて1にしたときの左端の位置
			rpos  = -1; //lenexすべて1にしたときの右端の位置
			phead = NULL;
			pnext = NULL;
			pprev = NULL;
			plast = NULL;
		}
		int calc(){
			lenex = l + len + r;
			return lenex;
		}
		bool operator ==(const zeroblock &r) const{
			return (index == r.index) ;
		}
		bool operator <(const zeroblock &r) const{
			return (this->lenex < r.lenex);
		}
		void printInfo(){
			printf("zeroblock: left=%d, len=%d, right=%d, lenex=%d, index=%d, lpos=%d, rpos=%d\n", l, len, r, lenex, index, lpos, rpos);
		}
};

long long N, K;
vector<zeroblock*> B;
map<int, zeroblock*, std::greater<int>> M;
//multiset<zeroblock> mst;
string S;

//pの前後をpを抜いたあとの状態に更新する。
//p自身のメンバ変数のポインタ情報の更新はしない。
void delItemFromMap(zeroblock *p){
	if(p == NULL) return;

	int w = p->lenex;
	zeroblock* ph = p->phead;
	zeroblock* pp = p->pprev;
	zeroblock* pn = p->pnext;
	zeroblock* pl = p->plast;
	//自身1つのみのとき
	if(pp != NULL && pp == p && pn == NULL){
		M[w] = NULL;
		return;
	}
	//自分の後ろがいる場合
	if(pn != NULL){
		//自分が先頭のとき
		if(ph == p){
			pn->phead = pn;
			pn->pprev = pn;
			pn->plast = ph->plast;
			M[w] = pn;
		}
		else{
			//自分の前がいる
			pp->pnext = pn;
			pn->pprev = pp;
		}
	}
	//自分が末尾の場合。自身1つのみの場合はすでに処理済なので2つ以上のみ考慮。
	else{
		pp->pnext = NULL;
		M[w]->plast = pp;
	}
}

void addTail(int w, zeroblock* p){
	if(p == NULL) return;

	if(M.count(w)== 0 || M[w] == NULL){
		M[w] = p;
		p->phead = p;
		p->pprev = p;
		p->pnext = NULL;
		p->plast = p;
	}
	else{
		zeroblock* ph = M[w];
		p->phead = ph;
		p->pprev = ph->plast;
		ph->plast->pnext = p;
		ph->plast = p;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	cin >> S;
	int al = 0, ar = 0, aindex = 0, alen = 0;
	zeroblock* b = NULL;
	for(int i=0; i<S.size(); i++){
		if((i == 0 && S[i] == '0') || (i > 0 && S[i-1] == '1' && S[i] == '0')){
			if(B.size() > 0){
				b = B[B.size()-1];
				b->r = ar;
				b->lenex = b->l + b->len + b->r;
				ar = 0;
			}
			b = new zeroblock();
			b->l = al;
			al = 0;
			alen = 0;
		}
		else if(i > 0 && S[i-1] == '0' && S[i] == '1'){
			b->len = alen;
			b->index = B.size();
			B.push_back(b);
			alen = 0;
			al = 0;
			ar = 0;
		}

		if(S[i] == '1'){
			ar++;
			al++;
			if(i == S.size()-1 && B.size() > 0){
				zeroblock* p = B[B.size()-1];
				b->r = ar;
			}
		}
		if(S[i] == '0'){
			alen++;
			if(i == S.size()-1){
				b->len = alen;
				b->index = B.size();
				B.push_back(b);
			}
		}

	}
	for(int i=0; i<B.size(); i++){
		zeroblock* b = B[i];
		//b->lenex = b->l + b->len + b->r;
		int v = b->calc();
		addTail(v, b);
		if(i == 0){
			b->lpos = 0;
			b->rpos = b->lenex - 1;
		}
		else{
			b->lpos = B[i-1]->lpos + B[i-1]->l + B[i-1]->len ;
			b->rpos = b->lpos + b->lenex - 1;
		}
	}

	// 最初からALL 1
	if(B.size() == 0){
		printf("%lld\n", N);
		return 0;
	}
	// 最初からALL 0
	if(B.size() == 1 && B[0]->len == N && K >= 1){
		printf("%lld\n", N);
		return 0;
	}

	LL ans = 0;
	int count = 0;
	while(count < K && count < B.size()){
		auto itr = M.begin();
		zeroblock* b = itr->second;
		while(b == NULL){
			itr++;
			b = itr->second;
		}
		int idx = b->index;
		int u = b->calc();
		ans = u;
		delItemFromMap(b);
		b->done = 1;
		if(idx > 0){
			int j = idx;
			while(j >=0 && B[j]->done == 1){
				j--;
			}
			if(j >= 0){
				zeroblock* p1 = B[j];
				delItemFromMap(p1);
				p1->r += (b->len + b->r);
				int w = p1->calc();
				addTail(w, p1);
			}
		}
		if(idx < B.size()-1){
			int j=idx;
			while(j < B.size() && B[j]->done == 1){
				j++;
			}
			if(j < B.size()){
				zeroblock* p2 = B[j];
				delItemFromMap(p2);
				p2->l += (b->l + b->len);
				int w = p2->calc();
				addTail(w, p2);
			}
		}
		count++;
	}

	//左からB[s]～B[e]をひっくり返す
	LL ans2 = 0;
	for(int s=0; ; s++){
		int e = min(s + (int)K - 1, (int)B.size() - 1);
		int c = B[e]->rpos - B[s]->lpos + 1;
		if(ans2 < c){
			ans2 = (LL)c;
		}
		if(e == B.size()-1){
			break;
		}
	}
	printf("%lld\n", max(ans, ans2));
	return 0;
}


Measured memory_bytes: 10992