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

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

/* define const */
const long long INF = (1LL << 60);
/* end defineing */

int main()
{
    int n, k;
    deque<int> z;
    deque<int> o;
    string s;
    cin >> n >> k;
    cin >> s;

    for (int i = 0; i < n;)
    {
        if (s[i] == '0')
        {
            int count = 0;
            int j = i;
            while (s[j] == '0')
            {
                if (j >= n)
                {
                    break;
                }
                j++;
                count++;
            }
            z.push_back(count);
            i = j;
        }
        else
        {
            int count = 0;
            int j = i;
            while (s[j] == '1')
            {
                if (j >= n)
                {
                    break;
                }
                j++;
                count++;
            }
            o.push_back(count);
            i = j;
        }
    }
    /*
    for (int i = 0; i < z.size(); i++)
    {
        cout << z[i] << ",";
    }
    cout << endl;
    for (int i = 0; i < o.size(); i++)
    {
        cout << o[i] << ",";
    }
    cout << endl;
*/
    int tmp_max = -1;
    int i = 0;

    if (s[0] == '0')
    {
        int tmp = 0;
        int j;
        for (j = 0; j < z.size() && j < k; j++)
        {
            tmp += z[j];
        }
        j--;
        int cc = 0;
        for (int m = j; m >= 0; m--)
        {
            if (cc > k)
            {
                break;
            }
            tmp += o[m];
            cc++;
        }
        tmp_max = tmp;
        // cout << tmp_max << endl;

        for (int n = k; n < z.size(); n++)
        {
            tmp -= z[n - k];
            tmp += z[n];
            if (n - k - 1 >= 0)
            {
                tmp -= o[n - k - 1];
            }
            if (n < o.size())
            {
                tmp += o[n];
            }
            /*
            if (n - k - 1 >= 0)
            {
                cout << "-" << z[n - k] << "+" << z[k] << "-" << o[n - k - 1] << "+" << o[k] << endl;
            }
            else
            {
                cout << "-" << z[n - k] << "+" << z[k] << "+" << o[k] << endl;
            }
*/
            if (tmp_max < tmp)
                tmp_max = tmp;

            // cout << tmp << endl;
        }
    }
    else
    {
        int tmp = 0;
        int j;
        for (j = 0; j < z.size() && j < k; j++)
        {
            tmp += z[j];
        }
        j--;
        int cc = 0;
        for (int m = j + 1; m >= 0; m--)
        {
            if (cc > k + 1)
            {
                break;
            }
            /*
            if (m >= o.size())
            {
                continue;
                cc++;
            }
            */
            tmp += o[m];
            cc++;
        }
        tmp_max = tmp;
        // cout << tmp << endl;

        for (int n = k; n < z.size(); n++)
        {
            tmp -= z[n - k];
            tmp += z[n];
            if (n - k >= 0)
            {
                tmp -= o[n - k];
            }
            if (n + 1 < o.size())
            {
                tmp += o[n + 1];
            }
            /*
            if (n - k >= 0)
            {
                cout << "-" << z[n - k] << "+" << z[n] << "-" << o[n - k] << "+" << o[n] << endl;
            }
            else
            {
                cout << "-" << z[n - k] << "+" << z[k] << "+" << o[k] << endl;
            }
*/
            // cout << "=" << z[n - k] << "a" << z[k] << "a" << o[n - k - 1] << "a" << o[k] << endl;
            if (tmp_max < tmp)
                tmp_max = tmp;

            // cout << tmp << endl;
        }
    }
    cout << tmp_max << endl;
}


Measured memory_bytes: 768