using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();
        string s = sc.Next();

        List<long> counts = new List<long>();
        List<bool> isZero = new List<bool>();

        if (s.Length == 1)
        {
            counts.Add(1);
            isZero.Add(s[0] == '0');
        }
        else
        {
            char before = s[0];
            long count = 1;
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] != before)
                {
                    counts.Add(count);
                    isZero.Add(before == '0');
                    count = 1;
                    before = s[i];
                }
                else
                {
                    count++;
                }
                if (i == s.Length - 1)
                {
                    counts.Add(count);
                    isZero.Add(before == '0');
                    break;
                }
            }
        }

        if (isZero.Where(z => z == true).Count() <= k)
        {
            Console.WriteLine(s.Length);
            return;
        }

        long answer = 0;

        int left = 0;
        int right = 0;
        long zeroCount = 0;
        for (int i = 0; i < counts.Count; i++)
        {
            if (zeroCount == k && isZero[i] == true)
            {
                break;
            }
            answer += counts[i];
            right = i;
            if (isZero[i])
            {
                zeroCount++;
            }
        }

        long tmpAnswer = answer;
        while (right < counts.Count)
        {
            tmpAnswer -= counts[left];
            left++;
            if (isZero[left - 1])
            {
                right++;
                if (right == counts.Count)
                {
                    break;
                }
                tmpAnswer += counts[right];
                answer = Math.Max(tmpAnswer, answer);
                if (isZero[right])
                {
                    right++;
                    if (right == counts.Count)
                    {
                        break;
                    }
                    tmpAnswer += counts[right];
                }
            }
            answer = Math.Max(tmpAnswer, answer);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 30404