#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for (llong i = 0; i < times; i++)
#define rloop(i, times) for (llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif


class ABC124D
{
public:
	ABC124D()
	{
		cin >> n_;
		cin >> k_;
		cin >> s_;
	}
	void Run(void)
	{
		CountBlock();

		if (ceil((double)count_.size() / 2 <= k_))
		{
			cout << count_.back();
			return;
		}

		llong ans = count_[2 * k_];
		llong i = 2;
		while (1)
		{
			// check_range[i, i+2*k_]がcount_のサイズを超えないように注意する
			if ((llong)count_.size() <= i + 2 * k_)
				break;
			
			ans = max(ans, count_[i + 2 * k_] - count_[i - 1]);
			i += 2;
		}
		if (i < (llong)count_.size())
			ans = max(ans, count_.back() - count_[i - 1]);
	
		cout << ans;
	}
private:
	void CountBlock(void)
	{
		// count_[0]はBlockEnd(0)+1
		// ただし、処理を単純化するためにs_[0]が'0'のときは先頭に長さ0の'1'文字列があることにする
		llong i = 0;
		if (s_[i] == '1')
		{
			count_.push_back(NextBlockIndex(0));
			i = NextBlockIndex(i);
		}
		else
		{
			count_.push_back(0);
		}

		while(i < n_)
		{	// 累積和の作成
			count_.push_back(count_.back() + NextBlockIndex(i) - i);
			i = NextBlockIndex(i);
		}
	}
	llong NextBlockIndex(llong index)
	{
		if (n_ <= index + 1)
			return index + 1;

		while (s_[index] == s_[index + 1])
			index++;

		return index + 1;
	}
	llong n_;
	llong k_;
	string s_;
	vector<llong> count_;
};

int main(void)
{
	ABC124D abc124d;
	abc124d.Run();

	return 0;
}


Measured memory_bytes: 1528