#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_;
		ans_ = 0;
	}
	void Run(void)
	{
		CreateBlock();

		if (s_[0] == '0' && (llong)block_.size() / 2 + 1 <= k_)
		{
			cout << s_.size();
			return;
		}
		else if (s_[0] == '1' && (llong)block_.size() / 2 <= k_)
		{
			cout << s_.size();
			return;
		}


		llong union_block = 0;
		llong start_index = 0;
		llong end_index = start_index + k_ * 2;

		if (s_[0] == '0')
		{
			loop(i, k_ * 2)
				ans_ += block_[i];
			start_index = 1;
			end_index = start_index + k_ * 2;
		}

		if (end_index < (llong)block_.size())
		{
			FirstUnionBlock(union_block, start_index, end_index);
			ans_ = max(ans_, union_block);
		}

		while(end_index < (llong)block_.size())
		{
			NextUnionBlock(union_block, start_index, end_index);
			ans_ = max(ans_, union_block);
		}

		LastUnionBlock(union_block, start_index);
		ans_ = max(ans_, union_block);

		cout << ans_;
	}
private:
	void FirstUnionBlock(llong& union_block, llong& start_index, llong& end_index)
	{
		for (llong i = start_index; i <= end_index; i++)
			union_block += block_[i];
		start_index += 2;
		end_index = start_index + k_* 2;
	}
	void NextUnionBlock(llong& union_block, llong& start_index, llong& end_index)
	{
		union_block = union_block - block_[start_index - 2] - block_[start_index - 1] + block_[end_index - 1] + block_[end_index];
		start_index += 2;
		end_index = start_index + k_ * 2;
	}
	void LastUnionBlock(llong& union_block, llong& start_index)
	{
		union_block = 0;
		for (llong i = start_index; i < (llong)block_.size(); i++)
			union_block += block_[i];
	}
	void CreateBlock(void)
	{
		llong s_index = 0;
		while(s_index < (llong)s_.size())
		{
			block_.push_back(BlockEnd(s_index) - s_index + 1);
			s_index += block_[(llong)block_.size()-1];
		}
	}
	llong BlockEnd(llong start_index)
	{
		llong end_index = start_index;

		while (s_[start_index] == s_[start_index + 1])
		{
			end_index++;
			start_index++;
		}

		return end_index;
	}

	llong n_;
	llong k_;
	string s_;
	vector<llong> block_;
	llong ans_;
};

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

	return 0;
}


Measured memory_bytes: 1528