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

# -*- coding: utf-8 -*-
k=int(input())
if k%7==0:
  l=9*k/7
else:
  l=9*k
if l%2==0 or l%5==0:
  print(-1)
i=1
while True:
  s=10**i
  if l<=s:
    break
  i+=1
while True:
  j=s%l
  if j==1:
    print(i)
    break
  i+=1
  s=j*10

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
s=7
for i in range(k):
  m=s%k
  if m==0:
    print(i+1)
    break
  s=m*10+7
### BUGGY CODE ###

N = int(input())
a = [input() for i in range(N)]
b = []
ans = []
flag = 1
for i in range(N):
    c = a.count(a[i])
    b.append(c)
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
for i in range(N):
    if b[i] == max:
        if(ans.count(a[i]) < 1):
            ans.append(a[i])
ans = sorted(ans, key=str.lower)

for i in range(len(ans)):
    print(ans[i])

### FIXED CODE ###

N = int(input())
a = [input() for i in range(N)]
a.sort()
b = [0] * N
flag = 1
cc = 0
bef = 132
c = 1
for i in range(N):
    if a[i] == bef:
        c = c + 1
    else:
        c = 1
    bef = a[i]
    b[i] = c
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
        
for i in range(N):
    if b[i] == max:
        print(a[i])
### BUGGY CODE ###

def root(parents, i):
    depth = 0
    while parents[i] != i:
        i = parents[i]
        depth += 1

    return i, depth

def isSame(parents, a, b):
    return root(parents,a)[0] == root(parents, b)[0]

def union(parents, size, a, b):
    pa, deptha = root(parents, a)
    pb, depthb = root(parents, b)
    if pa == pb: # already same group
        return
    if deptha < depthb:
        parents[pb] = pa
        size[pa] += size[pb]
    else:
        parents[pa] = pb
        size[pb] += size[pa]

def resolve():
    N, M, K = list(map(int, input().split()))
    parents = [i for i in range(N)]
    size = [1] * N
    ans = [0] * N

    for i in range(M):
        A, B = list(map(int, input().split()))
        ans[A-1] += 1
        ans[B-1] += 1
        union(parents, size, A-1, B-1)

    for i in range(N):
        pi = root(parents, i)[0]
        ans[i] = size[pi] - ans[i] -1 # eliminate friend count from candidate

    for i in range(K):
        A, B = list(map(int, input().split()))
        if isSame(parents, A-1, B-1):
            ans[A-1] -= 1
            ans[B-1] -= 1

    print(" ".join(map(str, ans)))

resolve()

### FIXED CODE ###

def root(parents, i):
    depth = 0
    while parents[i] != i:
        i = parents[i]
        depth += 1

    return i, depth

def isSame(parents, a, b):
    return root(parents,a)[0] == root(parents, b)[0]

def union(parents, size, a, b):
    pa, deptha = root(parents, a)
    pb, depthb = root(parents, b)
    if pa == pb: # already same group
        return
    if deptha < depthb:
        parents[pa] = pb
        size[pb] += size[pa]
    else:
        parents[pb] = pa
        size[pa] += size[pb]

def resolve():
    N, M, K = list(map(int, input().split()))
    parents = [i for i in range(N)]
    size = [1] * N
    ans = [0] * N

    for i in range(M):
        A, B = list(map(int, input().split()))
        ans[A-1] += 1
        ans[B-1] += 1
        union(parents, size, A-1, B-1)

    for i in range(N):
        pi = root(parents, i)[0]
        ans[i] = size[pi] - ans[i] -1 # eliminate friend count from candidate

    for i in range(K):
        A, B = list(map(int, input().split()))
        if isSame(parents, A-1, B-1):
            ans[A-1] -= 1
            ans[B-1] -= 1

    print(" ".join(map(str, ans)))

resolve()
### BUGGY CODE ###

N,M = map(int,input().split())
path = [[] for _ in range(N*3+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v+N)
    path[u+N].append(v+N+N)
    path[u+N+N].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [-1 for _ in range(N*3+3)]
def bfs():
    while len(q) > 0:
        now,cnt = q.popleft()
        #print(now,T,cnt,path[now],q)
        vis[now] = cnt
        if now == T: 
            return cnt
        for x in path[now]:
            if vis[x] == -1:
                q.append((x,cnt+1))
    return -3
vis[S] = 1
q.append([S,0])
print(bfs()//3)




### FIXED CODE ###

N,M = map(int,input().split())
import time
start_t = time.time()
path = [[] for _ in range(N+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [[-1 for _ in range(3)] for _ in range(N+3)]
vis[S][0] = 1
q.append([S,0])
while len(q):
    now,cnt = q.popleft()
    step = cnt % 3
    for x in path[now]:
        if vis[x][(step+1)%3] < 0:
            vis[x][(step+1)%3] = cnt
            q.append((x,cnt+1))

if vis[T][0] == -1:
    print(-1)
else:
    print(vis[T][0]//3+1)
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]
a = list(set(s))
ans = []

for i in range(len(a)):
	ans.append([s.count(a[i]),a[i]])

ans.sort(key=lambda x: x[1])
ans.sort(key=lambda x: x[0], reverse = True)

y = ans[0][0]

for i, j in ans:
	if y == i:
		print(j)




### FIXED CODE ###

import collections

n = int(input())
s = [input() for _ in range(n)]
a = list(set(s))
ans = []

t = collections.Counter(s)
v = list(t.most_common())[0][1]

for i,j in list(t.most_common()):
	if v == j:
		ans.append(i)

for i in sorted(ans):
	print(i)
### BUGGY CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def wa(d):
    for k in range(len(d)):
        for i in range(len(d)):
            for j in range(len(d)):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

N,M,L = m()

e = [[Max for i in range(N)]for j in range(N)]

for i in range(M):
    a,b,c = m()
    e[a-1][b-1] = c
    e[b-1][a-1] = c

for i in range(N):
    e[i][i] = 0

d = wa(e)


E = [[Max for i in range(N)]for j in range(N)]

for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            E[i][j] = 1

for i in range(N):
    E[i][i] = 0

E = wa(E)
q = onem()
for i in range(q):
    s,t = m()
    if E[s-1][t-1] == Max:
        print(-1)
    else:
        print(E[s-1][t-1]-1)



### FIXED CODE ###

import sys,collections as cl,bisect as bs
Max = 10**18
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())

def wa(d):
    for k in range(len(d)):
        for i in range(len(d)):
            for j in range(len(d)):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

def on():
    N,M,L = m()

    e = [[Max for i in range(N)]for j in range(N)]

    for i in range(M):
        a,b,c = m()
        e[a-1][b-1] = c
        e[b-1][a-1] = c

    for i in range(N):
        e[i][i] = 0

    d = wa(e)


    E = [[Max for i in range(N)]for j in range(N)]

    for i in range(N):
        for j in range(N):
            if d[i][j] <= L:
                E[i][j] = 1

    for i in range(N):
        E[i][i] = 0

    E = wa(E)
    q = onem()
    for i in range(q):
        s,t = m()
        if E[s-1][t-1] == Max:
            print(-1)
        else:
            print(E[s-1][t-1]-1)

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

N,K,Q=map(int,input().split())
a=[]
A=[]

for _ in range(Q):
    a.append(int(input()))

for _ in range(N):
    A.append(int(K))

for n in range(Q):
    A[a[n]-1]+=1
    for m in range(N):
        A[m]-=1
    
for s in range(N):
    if A[s]<1:
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

N,K,Q=map(int,input().split())
a=[]
A=[]

for _ in range(Q):
    a.append(int(input()))

for _ in range(N):
    A.append(int(K))

for n in range(Q):
    A[a[n]-1]+=1
    
for s in range(N):
    if A[s]-Q<1:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]
p.extend(readInts())
c = [0]
c.extend(readInts())

ans = -1*float("inf")
for i in range(1,n+1):
	t = [0]
	al = []
	j = p[i]
	while j not in al:
		t.append(t[-1]+c[j])
		al.append(j)
		j = p[j]
	if t[-1]<0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri = k//(len(t)-1)
		s = kuri*t[-1]
		ans = max(ans, max(s,s+max(t[:k-kuri*(len(t)-1)+1])))

print(ans)


### FIXED CODE ###

from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]+readInts()
c = [0]+readInts()

ans = -1*float("inf")
for i in range(1,n+1):
	j = p[i]
	t = [0]
	al = set()
	while j not in al:
		t.append(t[-1]+c[j])
		al.add(j)
		j = p[j]
	if t[-1]<=0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri =(k-1)//(len(t)-1)
		s = kuri*t[-1]
		re = k -kuri*(len(t)-1)
		ans = max(ans, max(s,s+max(t[:re+1])))

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

texts = str(input())
Q = int(input())


reverse = False
start_text = ''
end_text = ''
input_texts = []
for _ in range(Q):
    input_texts.append(list(input().split()))

for input_text in input_texts:
    if len(input_text) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if input_text[1] == '1':  # 先頭に
            if reverse:
                end_text += str(input_text[2])
            else:
                start_text = str(input_text[2]) + start_text
        else:  # 末尾に
            if reverse:
                start_text = str(input_text[2]) + start_text
            else:
                end_text += str(input_text[2])

if reverse:
    texts = list(start_text + texts + end_text)
    texts.reverse()
    print("".join(texts))
else:
    # texts = start_text + texts + end_text
    print(start_text + texts + end_text)


### FIXED CODE ###

from collections import deque
texts = deque(str(input()))
Q = int(input())


reverse = False
start_text = deque('')
end_text = deque('')
input_texts = []
for _ in range(Q):
    input_texts.append(list(input().split()))

for input_text in input_texts:
    if len(input_text) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if input_text[1] == '1':  # 先頭に
            if reverse:
                end_text.append(str(input_text[2]))
            else:
                start_text.appendleft(str(input_text[2]))
        else:  # 末尾に
            if reverse:
                start_text.appendleft(input_text[2])
            else:
                end_text.append(input_text[2])

# print(start_text, texts, end_text)
# print(''.join(texts))

texts.appendleft(''.join(start_text))
texts.append(''.join(end_text))
# print(''.join(texts))

# print(texts)
if reverse:
    texts = deque("".join(texts))
    texts.reverse()
    print("".join(texts))
else:
    # texts = start_text + texts + end_text
    print(''.join(texts))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=0
MOD=10**9+7
la=[0 for i in range(61)]
for i in range(61):
    la[60-i]=sum([j//2**(60-i) for j in l])
    l=[j%2**(60-i) for j in l]
for num,i in enumerate(la):
    ans+=2**num*i*(n-i)
    ans%=MOD
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l=[format(i,"b").zfill(61) for i in l]
ans=0
MOD=10**9+7
la=[0 for i in range(61)]
for i in l:
    for num,j in enumerate(str(i)):
        if j=="1":
            la[60-num]+=1
for num,i in enumerate(la):
    ans+=2**num*i*(n-i)
    ans%=MOD
print(ans)
### BUGGY CODE ###

a,b,n=map(int,input().split())
ans=0
for x in range(n+1):
  test_ans=int(a*x/b)-a*int(x/b)
  if test_ans>ans:
    ans=test_ans
print(ans)


### FIXED CODE ###

# floor(a/b)=(a-(a%b))/b
# ax%b=a(x%b)%b
a,b,n=map(int,input().split())
if(n>=b-1):
    print(a*(b-1)//b)
else:
    print(a*n//b)
### BUGGY CODE ###

S = input()
ans = 0
if int(S) < 2019:
  print(ans)
else:
  for i in range(len(S)-3):
    for j in range(3, len(S)-i+1):
      T = S[i:i+j]
      N = 0
      for k in range(len(T)):
        N += int(T[-(k+1)]) * (10**k)
      if N % 2019 == 0:
        ans += 1
  print(ans)

### FIXED CODE ###

s = input()
a = 0
mods = [0]*2019
mods[a] += 1
r = 1
for i in s[::-1]:
  a = (a+int(i)*r)%2019
  r = r*10%2019
  mods[a] += 1
ans = 0
for i in mods:
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
q=[]
for i in range(M):
    q.append(list(map(int,input().split())))
    
sorted_q=sorted(q,key=lambda x:x[1],reverse=True)

q_all=[]
for i in range(M):
    for j in range(sorted_q[i][0]):
        q_all.append(sorted_q[i][1])

if len(A)<=len(q_all):
    A.sort()
    for i in range(N):
        if A[i]<q_all[i]:
            A[i]=q_all[i]
else:
    A.sort()
    for i in range(len(q_all)):
        if A[i]<q_all[i]:
            A[i]=q_all[i]
        
print(sum(A))

### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            break
        A[cnt] = c
        cnt += 1
        if cnt >= n:
            break
    else:
        continue
    break

print(sum(A))
### BUGGY CODE ###

s = list(input())
q = int(input())
flag = True
ans = s

for i in range(q):
  query = list(input().split())
  if int(query[0]) == 1:
    flag = not flag
  else:
    if int(query[1]) == 1:
      if flag:
        ans.insert(0, query[2])
      else:
        ans.append(query[2])
    else:
      if flag:
        ans.append(query[2])
      else:
        ans.insert(0, query[2])

if flag:
  print("".join(ans))
else:
  t = ans[::-1]
  print("".join(t))

### FIXED CODE ###

s = input()
q = int(input())
revFlag = False
head, tail = [], []

for i in range(q):
  query = list(input().split())
  if int(query[0]) == 1:
    revFlag = not revFlag
  else:
    if int(query[1]) == 1:
      if not revFlag:
        head.append(query[2])
      else:
        tail.append(query[2])
    else:
      if not revFlag:
        tail.append(query[2])
      else:
        head.append(query[2])

if not revFlag:
  h = "".join(reversed(head))
  t = "".join(tail)
  print("".join([h, s, t]))
else:
  h = "".join(head)
  t = "".join(reversed(tail))
  print("".join([t, s[::-1], h]))
### BUGGY CODE ###

import sys
MX = 10**5
def main():
    input = sys.stdin.readline
    N = int(input())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    Q = int(input())
    vL = [tuple(map(int, input().split())) for _ in range(Q)]

    H = min(N + 1, 1 << 9)
    Hb = (H - 1).bit_length()
    dp = [[0] * (MX + 1) for _ in range(H)]
    for i in range(1, H):
        v, w = items[i - 1]
        dpi = dp[i]
        dpip = dp[i >> 1]
        for j in range(MX + 1):
            t = dpip[j]
            if j >= w:
                t = max(t, dpip[j - w] + v)
            dpi[j] = t
    for v, L in vL:
        if v < H:
            print(dp[v][L])
            continue
        ans = 0
        for i in range(1 << (v.bit_length() - Hb)):
            node = v
            value = weight = 0
            while node >= H:
                if i & 1:
                    value += items[node - 1][0]
                    weight += items[node - 1][1]
                node >>= 1
                i >>= 1
            if weight > L:
                continue
            ans = max(ans, value + dp[node][L - weight])
        print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
MX = 10**5
def main():
    data = map(int, sys.stdin.buffer.read().split())
    N = next(data)

    H = min(N + 1, 1 << 10)
    dp = [None] * H
    dp[0] = [0] * (MX + 1)
    IV, IW = [], []
    i = 1
    for v, w in zip(data, data):
        if i < H:
            dpi = dp[i >> 1][:]
            dp[i] = dpi
            for j in range(MX, w - 1, -1):
                dpi[j] = max(dpi[j], dpi[j - w] + v)
        else:
            IV.append(v)
            IW.append(w)
        i += 1
        if i > N:
            break

    Q = next(data)
    for v, L in zip(data, data):
        if v < H:
            print(dp[v][L])
            continue

        item_values = []
        item_weights = []
        while v >= H:
            item_values.append(IV[v - H])
            item_weights.append(IW[v - H])
            v >>= 1

        l = len(item_values)
        V = [0] * (1 << l)
        W = [0] * (1 << l)
        ans = dp[v][L]
        for i in range(1, 1 << l):
            msb = i & (-i)
            msbb = msb.bit_length() - 1
            wi = W[i - msb] + item_weights[msbb]
            W[i] = wi
            if wi <= L:
                vi = V[i - msb] + item_values[msbb]
                ans = max(ans, vi + dp[v][L - wi])
                V[i] = vi
        print(ans)

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

import copy
# N = int(input())
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

for i in range(K):
    B = [0 for k in range(N)]
    for j in range(N):
        L = A[j]
        for k in range(max(j-L, 0), min(j+L+1, N)):
            B[k] += 1
    A = copy.deepcopy(B)
    if len(set(A)) == 1 and A[0] == N:
        break
print(*A)


### FIXED CODE ###

# tokio marine 2020 C.Lamps
import copy
# N = int(input())
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

for i in range(K):
    B = [0 for k in range(N)]
    for j in range(N):
        L = A[j]
        l = max(j-L, 0)
        r = min(j+L, N-1)
        B[l] += 1
        if r + 1 < N:
            B[r+1] -= 1
    for j in range(1, N):
        B[j] += B[j-1]
    A = copy.deepcopy(list(B))
    if len(set(A)) == 1 and A[0] == N:
        break
print(*A)
### BUGGY CODE ###

n = int(input())
L = sorted(list(map(int, input().split())))
def isOK(target,a,b):
  return target > abs(a-b) and target < a+b

def bin_search(a,b):
  left = 1
  right = n
  while right-left>1:
    mid = left+(right-left)//2
    if isOK(L[mid],a,b):
      left = mid
    else:
      right = mid
  return left
ans = 0
for i in range(n):
  for j in range(i+1,n):
    a,b = L[i],L[j]
    ans += max(0, bin_search(a,b) - j)
      
print(ans)



### FIXED CODE ###

n = int(input())
L = sorted(list(map(int, input().split())))
def isOK(target,a,b):
  return target < a+b

def bin_search(a,b):
  left = 1
  right = n
  while abs(right-left)>1:
    mid = (left+right)//2
    if isOK(L[mid],a,b):
      left = mid
    else:
      right = mid
  return left
ans = 0
for i in range(n-2):
  for j in range(i+1,n):
    a,b = L[i],L[j]
    ans += max(0, bin_search(a,b) - j)
      
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9] * (n+k+10)
dp[0] = 0

for i in range(n):
    for j in range(1, k+1):
        if 0<=i+j<n: dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[n-1])

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9] * (n+k+10)
dp[0] = 0

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

# coding: utf-8
N = int(input())
S = input()
R, G, B = S.count("R"), S.count("G"), S.count("B")
ans = R * G * B
for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)

### FIXED CODE ###

# coding: utf-8
from collections import deque
N = int(input())
S = input()
Sd = deque(S)
ans = 0
R, G, B = 0, 0, 0
for i in range(N):
    p = Sd.popleft()
    if p == "R":
        R += 1
    elif p == "G":
        G += 1
    else:
        B += 1
ans = R * G * B
for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def main():
	N, K = MAP()
	S = input()

	flg = [S[0]]
	count = []
	cnt = 1
	tmp = S[0]

	for x in S[1:]:
		if x == tmp:
			cnt += 1
		else:
			tmp = x
			flg.append(tmp)
			count.append(cnt)
			cnt = 1
	count.append(cnt)

	ans = 0
	for i in range(len(flg)):
		if flg[i] == "1":
			ans = max(ans, sum(count[i:i+2*K+1]))
		else:
			ans = max(ans, sum(count[i:i+2*K]))

	print(ans)

if __name__ == '__main__':
	main()


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
#INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
S = [int(s) for s in input()] + [1]

r = -1
ans = 0
cnt = 0
used = [0]*(N+1)

for l in range(N):
	if S[l] + S[l-1] == 0:
		continue
	while r < N and used[r] - used[l-1] <= K:
		r += 1
		if S[r-1] == 1 and S[r] == 0:
			used[r] = used[r-1] + 1
		else:
			used[r] = used[r-1]
	ans = max(ans, r-l)

print(ans)