#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 998244353;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
//uniform_int_distribution(0,1)(rng)
string toString(long long x)
{
stringstream ss;
ss << x;
string str = ss.str();
return str;
}
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int rep[100005];
int main()
{
    IO;
    int n,k;
    string s;
    cin >> n >> k >> s;
    string tmp;
    queue<int> myQue;
    bool isZero = false;
    for(int i = 0;i < s.length();i++)
    {
        if(s[i] == '1')
        {
            tmp += '1';
            continue;
        } else {
            isZero = true;
            tmp += '0';
            int c = 0;
            while(s[i] == '0' && i < s.length())
                i++,c++;
            myQue.push(c);
            i--;
        }
    }
    if(!isZero)
    {
        cout << s.length();
        return 0;
    }
    vector<pair<int,pair<int,int> > > myVec;
    for(int i = 0;i < tmp.length();i++)
    {
        if(tmp[i] == '1')
            continue;
        pair<int,int> cnt = {0,0};
        if(tmp[i] == '0')
        {
            for(int j = i-1;j >= 0;j--)
            {
                if(tmp[j] == '1')
                    cnt.first++;
                else
                    break;
            }
            for(int j = i+1;j < tmp.length();j++)
            {
                if(tmp[j] == '1')
                    cnt.second++;
                else
                    break;
            }
        }
        myVec.push_back(make_pair(myQue.front(),cnt));
        myQue.pop();
    }
    int curBest = 0;
    int curC = 0;
    int iter = 0;
    for(;iter < k && iter < myVec.size();iter++)
    {
        //cout << myVec[iter].first << " " << myVec[iter].second.first << " " << myVec[iter].second.second << endl;
        curC += myVec[iter].first + myVec[iter].second.second;
        if(iter == 0)
            curC += myVec[iter].second.first;
    }
    //cout << curC << endl;
    curBest = max(curBest,curC);
    for(;iter < myVec.size();iter++)
    {
        curC -= myVec[iter-k].first;
        //cout << curC << " ";
        curC -= myVec[iter-k].second.first;
        //cout << curC << " ";
       // curC += myVec[iter-k+1].second.first;
        //cout << curC << " ";
        curC += myVec[iter].first + myVec[iter].second.second;
        //cout << curC << endl;
        //cout << curC << endl;
        curBest = max(curBest,curC);
    }
    cout << curBest;
    return 0;
}


Measured memory_bytes: 1616