Problem:
Score : 400 points

Problem Statement

N people are arranged in a row from left to right.

You are given a string S of length N consisting of 0 and 1, and a positive integer K.

The i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.

You will give the following direction at most K times (possibly zero):

Direction: Choose integers l and r satisfying 1 \leq l \leq r \leq N, and flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1, ..., r, the i-th person from the left now stands on hands if he/she was standing on feet, and stands on feet if he/she was standing on hands.

Find the maximum possible number of consecutive people standing on hands after at most K directions.

Constraints

N is an integer satisfying 1 \leq N \leq 10^5.

K is an integer satisfying 1 \leq K \leq 10^5.

The length of the string S is N.

Each character of the string S is 0 or 1.

Input

Input is given from Standard Input in the following format:

N K
S

Output

Print the maximum possible number of consecutive people standing on hands after at most K directions.

Sample Input 1

5 1
00010

Sample Output 1

4

We can have four consecutive people standing on hands, which is the maximum result, by giving the following direction:

Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.

Sample Input 2

14 2
11101010110011

Sample Output 2

8

Sample Input 3

1 1
1

Sample Output 3

1

No directions are necessary.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {
		SINT32 ANS = 0;

	SINT32 N = 0;
	SINT32 K = 0;
	SINT32 count = 0;
	SINT32 han01 = 0;
	SINT32 Fhan01 = 0;
	SINT32 Lhan01 = 0;

	cin >> N;
	cin >> K;

	SINT8 S[1000000];
	for (SINT32 i = 0; i < 1000000; i++) {
		S[i] = 'A';
	}

	cin >> S;

	vector<SINT32> DATA(N);


	if (S[0] == '0') {
		han01 = 0;
		Fhan01 = 0;
	} else {
		han01 = 1;
		Fhan01 = 1;
	}
	if (S[N-1] == '0') {
		Lhan01 = 0;
	} else {
		Lhan01 = 1;
	}
	count = 0;

		
	for (SINT32 i = 0; i < N; i++) {
		if (S[i] == 'A') {
			break;
		}

		if (han01 == 0) {
			if (S[i] == '0') {
			} else {
				han01 = 1;
				count++;
			}
		} else {
			if (S[i] == '0') {
				han01 = 0;
				count++;
			} else {	
			}
		}
		DATA[count] = DATA[count]+1;			
	}

/*	for (SINT32 i = 0; i < count+4; i++) {
		cout << DATA[i] << " ";
 	}
	cout << endl;
	*/

	vector<SINT32> SA(count+5);

	SA[0] = 0;
	SA[1] = 0;
	
	for (SINT32 i = 2; i < count+3; i++) {
		SA[i] = DATA[i-2] + SA[i-1];
 	}
	SA[count+3] = SA[count+2];
	SA[count+4] = SA[count+3];


/*
	for (SINT32 i = 0; i < count+4; i++) {
		cout << SA[i] << " ";
 	}
	cout << endl;
	*/

	ANS = 0;

if (Fhan01 == 0) {
	for (SINT32 i = 2*K+1; i < count+5; i++) {
		ANS = MAX(ANS, SA[i] - SA[i - (2*K+1)]);
//		cout << SA[i] << " " <<SA[0] <<endl;
		i++;
 	}
} else {
	for (SINT32 i = 2*K; i < count+5; i++) {
		ANS = MAX(ANS, SA[i] - SA[i - (2*K+1)]);
//		cout << SA[i] << " " <<SA[0] <<endl;
		i++;
 	}

}



	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();