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<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
const double E=exp(1);
const double PI=acos(-1);
using namespace std;
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c*=a;
        a*=a;
        b>>=1;
    }return c;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
bool cmp(int a,int b)
{
    return a>b;
}
int ans[100003];
int ans1[100003];
int sum;
int sum1;
int main()
{
   int n,m;
   cin>>n>>m;
   string s;
   cin>>s;
   int z=0;
  if(s[0]=='0')ans1[++sum1]++;
  else ans[++sum]++;
   for(int i=1;i<n;i++)
    { int a=s[i]-'0';
        if(a==0)
        {    if(s[i]==s[i-1])
            ans1[sum1]++;
            else ans1[++sum1]++;
        }
        else {
            if(s[i]==s[i-1])ans[sum]++;
            else ans[++sum]++;
        }
    }//cout<<sum<<endl;
    for(int i=1;i<=sum+m;i++)
        ans[i]+=ans[i-1];
    for(int i=1;i<=sum1+m;i++)
        ans1[i]+=ans1[i-1];
        for(int i=1;i<=sum;i++)
        {
           // cout<<ans[i]<<endl;
        }
    int Max=0;
    for(int i=1;i<=sum1;i++)
    {
        int S=0;
        if(s[0]=='1')  S+=ans[i+m]-ans[i-1];
        else  S+=ans[i+m-1]-ans[i-1];

        S+=ans1[i+m-1]-ans1[i-1];

        Max=max(Max,S);
    }
    if(Max==0)Max=ans[sum];
    cout<<Max<<endl;
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/