Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
l = list(map(int, input().split()))

x = 1
for i in range(N):
    x = x * l[i]

if x > (1000000000000000000):
    x = -1
    print(x)
else:
    print(x)

### FIXED CODE ###

import sys

N = int(input())
l = list(map(int, input().split()))

def solve():
    if 0 in l:
        return (0)
        sys.exit()

    x = 1
    for i in range(N):
        x = x * l[i]
        if x > (1000000000000000000):
            x = -1
            break

    return str(x)

print(solve())
### BUGGY CODE ###


def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    dp = [-1] * n
    r = min(n, k + 1)
    for i1 in range(1, r):
        dp[i1] = abs(h[i1] - h[0])

    for i1 in range(2, n):
        start = max(1, i1 - k)
        cost = dp[start] + abs(h[i1] - h[start])
        for i2 in range(start + 1, i1):
            cost = min(cost, dp[i2] + abs(h[i2] - h[i1]))
        if dp[i1] < 0:
            dp[i1] = cost
        else:
            dp[i1] = min(cost, dp[i1])
    print(dp[n - 1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

n,k  = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
for i in range(1, n):
  start = max(0, i - k)
  dp[i] = dp[start] + abs(h[start] - h[i])
  for j in range(start+1, i + 1):
    dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]))
  
print(dp[n-1])
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        b = (N - r*R - g*G) / B
        if b >= 0 and b.is_integer():
            ans += 1
print(ans)


### FIXED CODE ###

R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        b = (N - r*R - g*G) / B
        if b >= 0 and b.is_integer():
            ans += 1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]
    A = [b for a, b in AB if a == 1]
    B = [a for a, b in AB if b == N]

    result = 'IMPOSSIBLE'
    for a in A:
        if a in B:
            result = 'POSSIBLE'
    print(result)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    # AB = [list(map(int, input().split())) for _ in range(M)]
    from_1 = [False] * N
    to_N = [False] * N
    for _ in range(M):
        a, b = map(int, input().split())
        if a == 1:
            from_1[b - 1] = True
        elif b == N:
            to_N[a - 1] = True
    for i in range(1, N):
        if from_1[i] and to_N[i]:
            print('POSSIBLE')
            break
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import itertools
N, A = map(int, input().split())
x = sorted([int(i)-A for i in input().split()])
ans = x.count(0)

if N >= 2:
    for i in range(2, N+1):
        check = list(itertools.combinations(x,i))
        for i in check:
            if sum(i) == 0:
                ans += 1

print(ans)

### FIXED CODE ###

N, A = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]
 
dp = [[0] * (sum(x)+1) for j in range(N+1)]
 
dp[0][0] = 1
for i in range(1, N+1):
    for j in list(range(1, N+1))[::-1]:
        for k in list(range(x[i-1], sum(x[:i])+1))[::-1]:
            dp[j][k] += dp[j-1][k - x[i-1]]
 
print(sum([dp[i][i*A] for i in range(1, N+1) if i*A <= sum(x)]))
### BUGGY CODE ###

mini, maxi, K_ban = map(int, input().split())

num_list = [i for i in range(mini, maxi + 1)]

if (maxi - mini + 1 <= 2 * K_ban):
    ans = num_list
else:
    ans = num_list[:K_ban] + num_list[-K_ban:]


[print(n) for n in ans]

### FIXED CODE ###

mini, maxi, K_ban = map(int, input().split())

if (maxi - mini + 1 <= 2 * K_ban):
    ans = [i for i in range(mini, maxi + 1)]

else:
    left = [i for i in range(mini, mini + K_ban)]
    right = [i for i in range(maxi - K_ban + 1, maxi + 1)]
    
    ans = left + right
    

[print(n) for n in ans]
### BUGGY CODE ###

import sys

_ = input()
S = input().strip()
flag = [1 if S[i:i+2] == 'AC' else 0 for i in range(len(S)-1)]

for line in sys.stdin:
  l,r = list(map(int, line.strip().split(' ')))
  print(sum(flag[l-1:r-1]))

### FIXED CODE ###

import sys
_ = input()
S = input().strip()

ps = [0]*(len(S)+1)
for i in range(2, len(S)+1):
  ps[i] = ps[i-1]+int(S[i-2:i] == 'AC')

for line in sys.stdin:
  l,r = map(int, line.strip().split(' '))
  print(ps[r]-ps[l])
### BUGGY CODE ###

def main():
    N = int(input())
    S = input()
    min = N
    for i in range(0, N):
        m = S[i]
        l = S[:i]
        r = S[i:]
        c = 0
        for h in l:
            if h != 'E': c += 1
        if c > min: continue
        for h in r:
            if h != 'W': c += 1
        if min > c: min = c
    print(min)
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    ec = S.count('E')
    tec = ec
    for k in S:
        if k == 'E':
            tec -= 1
        else:
            tec += 1
        ec = min(ec, tec)
    print(ec)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = list(input())
Q = int(input())
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
    if q[0] == '1':
        reverse = not reverse
    else:
        if q[1] == '1':
            S.append(q[2]) if reverse else S.insert(0, q[2])
        else:
            S.insert(0, q[2]) if reverse else S.append(q[2])
if reverse:
    S.reverse()
print(''.join(S))


### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
query = [input().split() for _ in range(Q)]
reverse = False
for q in query:
    if q[0] == '1':
        reverse = not reverse
    else:
        if q[1] == '1':
            if not reverse:
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if not reverse:
                S.append(q[2])
            else:
                S.appendleft(q[2])
if reverse:
    S.reverse()
print(''.join(S))
### BUGGY CODE ###

n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
seta=set(a)
lenseta=len(seta)

mylist=[a.count(i) for i in seta]
mylist.sort(reverse=True)

#print(mylist)
val=sum(mylist[:k])
  
print(n-val)

### FIXED CODE ###

import collections

n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)
### BUGGY CODE ###

class SegmentTree:

    def __init__(self, n, sentinel=0):
        n2 = 1 << (n - 1).bit_length()
        self.n = n2
        self.data = [sentinel] * ((n2 << 1) - 1)
        self.offset = n2 - 1

    def update(self, k, x):
        i = k + self.offset
        self.data[i] = x
        while i:
            p = (i - 1) // 2
            if self.data[p] > self.data[i]:
                self.data[p] = self.data[i]
            else:
                break
            i = p

    def get_left_min(self, k):
        i = k + self.offset - 1
        ret = self.data[i]
        while i:
            if i % 2 == 0:
                ret = min(ret, self.data[i - 1])
            i = (i - 1) // 2
        return ret

    def get_right_min(self, k):
        i = k + self.offset + 1
        ret = self.data[i]
        while i:
            if i % 2 == 1:
                ret = min(ret, self.data[i + 1])
            i = (i - 1) // 2
        return ret


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


n, d = map(int, input().split())
aaa = list(map(int, input().split()))
seg_l = SegmentTree(n, (10 ** 10, -1))
seg_r = SegmentTree(n, (10 ** 10, -1))
bbb = sorted((a, i) for i, a in enumerate(aaa))
edges = set()

for a, i in bbb:
    cost_l = -i * d + a
    cost_r = i * d + a
    seg_l.update(i, (cost_l, i))
    seg_r.update(i, (cost_r, i))

    di = i * d
    if i > 0:
        base_cost, j = seg_l.get_left_min(i)
        if j > -1:
            edges.add((base_cost + di + a, j, i))
    if i < n - 1:
        base_cost, j = seg_r.get_right_min(i)
        if j > -1:
            edges.add((base_cost - di + a, i, j))

uft = UnionFind(n)
ans = 0
for c, i, j in sorted(edges):
    if uft.find(i, j):
        continue
    ans += c
    uft.union(i, j)

print(ans)


### FIXED CODE ###

from itertools import accumulate
from operator import itemgetter

n, d = map(int, input().split())
aaa = list(map(int, input().split()))
costs_l = [(-i * d + a, i) for i, a in enumerate(aaa)]
costs_r = [(i * d + a, i) for i, a in enumerate(aaa)]

costs_l = list(accumulate(costs_l, min))
costs_r = list(accumulate(reversed(costs_r), min))
costs_r.reverse()

hubs = set(map(itemgetter(1), costs_l))
hubs.intersection_update(map(itemgetter(1), costs_r))
hubs.add(0)
hubs.add(n - 1)
hubs = sorted(hubs)

ans = sum(aaa) - aaa[-1]
s = hubs[0]
for t in hubs[1:]:
    cls = costs_l[s][0]
    crt = costs_r[t][0]
    ans += crt - s * d
    ans += sum(min(cls + i * d, crt - i * d) for i in range(s + 1, t))
    s = t
print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
b=A[0]

for i in range(1,len(A)):
    b=b*A[i]
    
if(10**18<b):

    print('-1')
    exit()

print(b)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
b=A[0]

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()
        
print(b)
### BUGGY CODE ###

k, s = map(int, input().split())

a = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                a+=1
            else:
                continue

print(a)


### FIXED CODE ###

k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n, k = MI()
p = list(MI())
c = list(MI())

p.insert(0, 0)
c.insert(0, 0)

ans = -float("INF")
for i in range(1, n + 1):
    start = i
    next = p[i]
    loop_score = 0
    score = 0
    MAX = -float("INF")
    for j in range(1, k + 1):
        score += c[next]
        MAX = max(MAX, score)
        if next == start:
            loop_score = score
            loop_size = j
            if loop_score > 0:
                q, r = divmod(k, loop_size)
                # 周れるだけ周る-1+余りの回数で最大となるマス動く
                score1 = loop_score * (q - 1) + MAX
                # 周れるだけ周る+余りの回数で最大となるマス動くとき
                score2 = loop_score * q
                MAX = score2
                next = p[i]
                for _ in range(1, r + 1):
                    score2 += c[next]
                    MAX = max(MAX, score)
                    next = p[next]
                score = max(score1, score2)
                break
            else:
                # 一周未満
                score = MAX
                break
        else:
            next = p[next]
    ans = max(ans, score)


print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n, k = MI()
p = list(MI())
c = list(MI())

p.insert(0, 0)
c.insert(0, 0)

ans = -float("INF")
for i in range(1, n + 1):
    next = p[i]
    score = 0
    MAX = -float("INF")

    for j in range(1, k + 1):
        score += c[next]
        MAX = max(MAX, score)
        if next == i:
            loop_score = score
            loop_size = j
            if loop_score > 0:
                q, r = divmod(k, loop_size)
                # 周れるだけ周る-1+余りの回数で最大となるマス動く
                score1 = loop_score * (q - 1) + MAX
                # 周れるだけ周る+余りの回数で最大となるマス動くとき
                score2 = loop_score * q
                MAX = score2
                next = p[i]
                for _ in range(1, r + 1):
                    score2 += c[next]
                    MAX = max(MAX, score2)
                    next = p[next]
                score = max(score1, MAX)
                break
            else:
                # 一周未満
                score = MAX
                break
        else:
            next = p[next]
    else:
        score = MAX

    ans = max(ans, score)


print(int(ans))
### BUGGY CODE ###

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix, lil_matrix
import sys
input = sys.stdin.readline
n,m,s,t = map(int, input().split())
money = lil_matrix((n+1, n+1), dtype = int)
snu = lil_matrix((n+1, n+1), dtype = int)
for i in range(m):
    u,v,a,b = map(int, input().split())
    money[u,v] = money[v,u] = a
    snu[u,v] = snu[v,u] = b
money = dijkstra(money, indices=s,directed=False)
snu = dijkstra(snu, indices=t,directed=False)
start = 10**15
#何年目か？
ans = []
ans_max = 10**15
for j in range(n,-1,-1):
    ans_max = min(ans_max, (money[j] + snu[j]))
    ans.append(ans_max)
for i in range(n-1,-1,-1):
    print(int(start - ans[i]))

### FIXED CODE ###

import numpy as np
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (n+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

n,m,s,t = map(int, input().split())
graph = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int, input().split())
    graph[u].append([v,a,b])
    graph[v].append([u,a,b])
money = dijkstra(s,0)
snu = dijkstra(t,1)
start = 10**15
#何年目か？
ans = []
ans_max = 10**15
for j in range(n,-1,-1):
    ans_max = min(ans_max, (money[j] + snu[j]))
    ans.append(ans_max)
for i in range(n-1,-1,-1):
    print(int(start - ans[i]))
### BUGGY CODE ###

n, k = map(int, input().split())
hlis = list(map(int, input().split()))
dp = [0] + [float('inf')]*(n-1)
dp[1] = abs(hlis[0] - hlis[1])
for i in range(2,n):
    dp[i] = min(dp[j] + abs(hlis[i] - hlis[j]) for j in range(max(0, i-k), i))
print(dp[n-1])

### FIXED CODE ###

N, K = map(int, input().split())
hlis = list(map(int, input().split()))
dp = [float('inf')]*(N+1)
dp[1] = 0
for i in range(1, N):
    for j in range(1,min(K+1, N-i+1)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(hlis[i-1]-hlis[i+j-1]))
print(dp[-1])
### BUGGY CODE ###

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

yoko = []
for v in s:
    v.append('-')
    tmp = []
    nc =v[0]
    nn = 0
    for c in v:
        if nc == c:
            nn += 1
            continue
        else:
            if nc == '#':
                tmp = tmp + [0 for _ in range(nn)]
            else:
                tmp = tmp + [nn for _ in range(nn)]
            nc = c
            nn = 1
    yoko.append(tmp)

tate = []
for j in range(w):
    tmp = []
    nc = s[0][j]
    nn = 0
    for i in range(h):
        c = s[i][j]
        if nc == c:
            nn += 1
            continue
        else:
            if nc == '#':
                tmp = tmp + [0 for _ in range(nn)]
            else:
                tmp = tmp + [nn for _ in range(nn)]
            nc = c
            nn = 1
    if nc == '#':
        tmp = tmp + [0 for _ in range(nn)]
    else:
        tmp = tmp + [nn for _ in range(nn)]
    tate.append(tmp)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)


### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v = v + '-'
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h):
            c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        if nc == '#':
            tmp.extend([0 for _ in range(nn)])
        else:
            tmp.extend( [nn for _ in range(nn)])
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)
### BUGGY CODE ###

# coding: utf-8

n = int(input())
a = [int(x) for x in input().split()]

count = 0

for i in range(0, n):
    for j in range(i, n):
        xor_result = 0
        sum_result = 0
        result_bool = True
        for x in a[i:j+1]:
            if sum_result & x != 0:
                result_bool = False
                break
            xor_result ^= x
            sum_result += x
        if not result_bool:
            break
        if xor_result == sum_result and result_bool:
            count += 1

print(count)

### FIXED CODE ###

# coding: utf-8

n = int(input())
a = [int(x) for x in input().split()]

count = 0
xor_result = 0
sum_result = 0
r = 0

for l in range(0, n):
    while r < n:
        x = a[r]
        if sum_result & x != 0:
            break
        xor_result ^= x
        sum_result += x
        r += 1
    count += r - l
    xor_result ^= a[l]
    sum_result -= a[l]

print(count)
### BUGGY CODE ###

import sys
import math
from bisect import bisect_left as bl

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    b=[b[i]%(2*T) for i in range(N)]
    b.sort()
    tmp=0
    for j in range(N):
        x=a[j]%(2*T)
        tmp+= -bl(b,T-x)+bl(b,2*T-x)-bl(b,3*T-x)+bl(b,4*T-x)
    ans+=(tmp%2)*T

print(ans)

### FIXED CODE ###

import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()

    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)    
    if np.sum(-left1 + right1 -left2 +right2) % 2: ans+=T

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python

H, W, M = map(int, input().split())
h = [-1 for _ in range(M)]
w = [-1 for _ in range(M)]
s = []
for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    s.append([h[i], w[i]])

# calc
hs = [0 for _ in range(H)]
ws = [0 for _ in range(W)]
for i in range(M):
    hs[h[i]] += 1
    ws[w[i]] += 1

#print('hs =', hs)
#print('ws =', ws)

hmax = max(hs)
wmax = max(ws)

ks = []
js = []

# 最大値の荷物がある場所を覚えておく
for k in range(H):
    if hmax == hs[k]:
        ks.append(k)
for j in range(W):
    if wmax == ws[j]:
        js.append(j)

ans = hmax + wmax

# クロスする場所に荷物があるかないかの確認
for k in range(len(ks)):
    for j in range(len(js)):
        if [ks[k], js[j]] not in s:
            print(ans)
            exit()
print(ans-1)

### FIXED CODE ###

#!/usr/bin/env python

H, W, M = map(int, input().split())
h = [-1 for _ in range(M)]
w = [-1 for _ in range(M)]
s = set()
for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    s.add((h[i], w[i]))

# calc
hs = [0 for _ in range(H)]
ws = [0 for _ in range(W)]
for i in range(M):
    hs[h[i]] += 1
    ws[w[i]] += 1

#print('hs =', hs)
#print('ws =', ws)

hmax = max(hs)
wmax = max(ws)

ks = []
js = []

# 最大値の荷物がある場所を覚えておく
for k in range(H):
    if hmax == hs[k]:
        ks.append(k)
for j in range(W):
    if wmax == ws[j]:
        js.append(j)

ans = hmax + wmax

# クロスする場所に荷物があるかないかの確認
for k in range(len(ks)):
    for j in range(len(js)):
        if (ks[k], js[j]) not in s:
            print(ans)
            exit()
print(ans-1)
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]
s = input()

l = []
if s[0] == "0":
    l.append(0)
one = []
cnt_0 = 0
cnt_1 = 0

for i in s:
    if i == '0':
        if cnt_1 != 0:
            l.append(cnt_1)
            one.append((cnt_1))
            cnt_1 = 0
        cnt_0 += 1
    if i =='1':
        if cnt_0 != 0:
            l.append(cnt_0)
            cnt_0 = 0
        cnt_1 += 1

if cnt_1 != 0:
    l.append(cnt_1)
    one.append(cnt_1)
if cnt_0 != 0:
    l.append(cnt_0)
    l.append(0)

#print(one)
#print(l)


ans = 0

for i in range(0,len(l),2):
    #print(sum(l[i:+i+k*2+1]))
    if ans < sum(l[i:i+k*2+1]):
        ans = sum(l[i:i+k*2+1])

"""
if len(one) == 0:
    print(sum(l))

elif len(one) == 1:
    for i in range(len(l)):
        if ans < sum(l[i:i+2]):
            ans = sum(l[i:i+2])

if len(one) >= 2:
    for i in range(len(l)):
        if ans < sum(l[i:(k*2+1)+1]):
            ans = sum(l[i:(k*2+1)+1])
"""

print(ans)


### FIXED CODE ###

n, k = [int(i) for i in input().split()]
s = input()

l = []
if s[0] == "0":
    l.append(0)
one = []
cnt_0 = 0
cnt_1 = 0

for i in s:
    if i == '0':
        if cnt_1 != 0:
            l.append(cnt_1)
            one.append((cnt_1))
            cnt_1 = 0
        cnt_0 += 1
    if i =='1':
        if cnt_0 != 0:
            l.append(cnt_0)
            cnt_0 = 0
        cnt_1 += 1

if cnt_1 != 0:
    l.append(cnt_1)
    one.append(cnt_1)
if cnt_0 != 0:
    l.append(cnt_0)
    l.append(0)

#print(l)
ans = 0
Sum = [0]
for i in range(len(l)):
    Sum.append(l[i]+Sum[i])
#print(Sum)

for i in range(1,len(Sum),2):
    left = i-1
    if i+k*2 > len(Sum)-1:
        right = len(Sum)-1
    else:
        right = i+k*2
    #print(left,right)
    temp = Sum[right] - Sum[left]
    if ans < temp:
        ans = temp
print(ans)