// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList1 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList1[0];
    const K = numList1[1];
    const SCharList = input[1].split(' ')[0];
  	if (SCharList.includes('0') === false) {
    	console.log(SCharList.length);
		return;
    }

    const length = SCharList.length;
    var baseC = SCharList[0];

    var cnt = 1;
    const sameCountList = [];
    for (var i = 1; i < length; i++) {
        var tempC = SCharList[i];
        if (baseC === tempC) {
            cnt++;
        } else {
            sameCountList.push(cnt);
          	baseC = tempC;
            cnt = 1;
        }
    }
  	if (baseC === tempC) {
	  	sameCountList.push(cnt);
    }
    // 最初が0の時
    if (SCharList[0] === '0') {
        // 先頭に1の個数を入れる
        sameCountList.unshift(0);
    }
    // 最後が0の時
    if (SCharList[SCharList.length - 1] === '0') {
        // 最後に1の個数を入れる
        sameCountList.push(0);
    }

    // 101の数の配列を作る
    const oneZeroOneList = [];
    for (var i = 0; i < sameCountList.length;) {
        oneZeroOneList.push([sameCountList[i], sameCountList[i + 1], sameCountList[i + 2]]);
        i += 2;
      	if (i + 2 > sameCountList.length) {
          break;
        }
    }
  
    // ここからが本番の処理
    // 足して一番大きくなる箇所を探す
    const reducer = (accumulator, currentValue) => accumulator + currentValue;
    for (var j = 0; j < K; j++) {
        var max = 0;
        var index = -1;
        for (var i = 0; i < oneZeroOneList.length; i++) {
            var array = oneZeroOneList[i];
            var sum = array.reduce(reducer);
            if (sum > max) {
                max = sum;
                index = i;
            }
        }
      	if (index === 0) {
          oneZeroOneList[index + 1][0] = max;
          oneZeroOneList.splice(index, 1);
        } else if (index !== -1) {
            oneZeroOneList[index - 1][2] = max;
            oneZeroOneList.splice(index, 1);
        }  	
    }

    // 最大値を探しに行く
    for (var i = 0; i < oneZeroOneList.length; i++) {
        var array = oneZeroOneList[i];
      	var value1 = array[0];
        var value2 = array[2];
        max = Math.max(value1, value2);

    }

    console.log(max);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));