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

#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back

int main() {
int n,k; cin>>n>>k;
string s; cin>>s;
vector<pair<int,int>> res;
f(i,0,n) {
int j = i;
while (j < n && s[i] == s[j]) j++;
res.pb({j-i,s[i]-'0'});
i = j-1;
}
int sum = 0, num = 0, j = 0;
int ans = 0;
f(i,0,res.size()) {
while (j < res.size() && num+(res[j].second==0) <= k) {
num += res[j].second == 0;
sum += res[j].first;
j++;
}
ans = max(ans,sum);
if (res[i].second == 0) num--;
sum -= res[i].first;
}
cout << ans << endl;
return 0;
}