Harryxun/stf_run huggingface dataset:
N,A,B,C,D = map(int,input().split())
S = list(input())
ans = "Yes"
is_reversed = False
flag = False

if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
if is_reversed == True:
  for i in range(B - 2,D - 1):
    if S[i] == S[i + 1] == S[i + 2] == ".":
 
  if flag == False:
    ans = "No"
print(ans)

### FIXED CODE ###

N,A,B,C,D = map(int,input().split())
S = list(input())
#pre = S[B - 2]
ans = "Yes"
is_reversed = False
flag = False
# cnt = 0
# max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
if is_reversed == True:
  for i in range(B - 2,D - 1):
    if S[i] == S[i + 1] == S[i + 2] == ".":
      flag = True
    # if S[i] == ".":
    #   cnt += 1
    # elif S[i] == "#":
    #   cnt = 0
    # max_cnt = max(max_cnt,cnt)
    # pre = S[i]
  # if is_reversed == True and max_cnt < 3:
  #   ans = "No"
  if flag == False:
    ans = "No"
print(ans)
N = int(input())
ls = list(map(int, input()))
anls = [0]*(N+1)
for i in ls:
    anls[i] += 1
for i in range(1,N+1):
    print(anls[i])


### FIXED CODE ###

N = int(input())
ls = list(map(int, input().split()))
anls = [0]*(N+1)
for i in ls:
    anls[i] += 1
for i in range(1,N+1):
    print(anls[i])
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

print(l1)
H = int(l1[0])
N = int(l1[1])
A = int(sum(l2))
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

def attack(l):
    H = l[0]
    A = l[1]
    cnt = 0
    while H > 0:
        H -= A
        cnt += 1
    return cnt

print(attack(l))
X, N = map(int,input().split(' '))
if N == 0:
    print(X)
    exit()

p = input().split(' ')
p =[int(i) for i in p]
num_list = [int(i+1) for i in range(100)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

print(num_list[tmp.index(min(tmp))])


### FIXED CODE ###

X, N = map(int,input().split(' '))
if N == 0:
    print(X)
    exit()

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i) for i in range(102)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min(tmp))

print(num_list[ans])
N,K=map(int,input().split())
h=input().split()
c=0

for i in range(M):
  if int(h[i])>K:
    c+=1
print(c)

### FIXED CODE ###

N,K=map(int,input().split())
h=input().split()
S=0

for i in range(N):
    if int(h[i]) >= K:
        S+=1

print(S)
A = input().split()
print(count(A[0]))

### FIXED CODE ###

A = input()
B = [i for i in A]
B.sort()
if B.count(B[0]) == 2:
  if B.count(B[-1]) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")
import math

r = int(input())

h = R * R * math.pi

print(h)

### FIXED CODE ###

import math
r = int(input())
h = 2 * r * math.pi
print(h)
N = int(input())
ab = []
for i in N:
    ab.append(tuple(map(int,input.split())))
ans = N
mx = max(ab,key=lambda x:x[1])[0]
ans += mx - 1
mn = min(ab,key=lambda x:x[1])[1]
ans += mn
print(ans)

### FIXED CODE ###

N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
mn = min(ab,key=lambda x:x[1])
print(sum(mn))
X, N = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(50):
  if X-i not in ps:
    print(X-i)
    break
  elif X+i not in ps:
    print(X+i)
    break

### FIXED CODE ###

X = list(map(int, input().split()))
for i in range(len(X)):
  if X[i] == 0:
    print(i+1)
    break
N = int(input())
L = list(map(int, input().split()))

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]) and (L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]):
                cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] <= L[k] or L[i] + L[k] <= L[j] or L[j] + L[k] <= L[i]:
                continue
            cnt += 1
print(cnt)
x = int(input())
target = 753
ok = 999
for i in range(len(x)-3):
	num = x[i:i+3]
	sa = target - num
	if (ok < sa):
		ok = sa
print (sa)

### FIXED CODE ###

x = str(input())
target = 753
ok = 999
for i in range(len(x)-2):
	num = x[i:i+3]
	sa = abs(target - int(num))
	if (ok > sa):
		ok = sa
	#print (sa)
print (ok)
N = input()
N = int(N[2])
if N == 3:
    print('bon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('hon')


### FIXED CODE ###

N = input()
N = int(N[-1])
if N == 3:
    print('bon')
elif N in [0,1,6,8]:
    print('pon')
else:
    print('hon')
N = int(input())
ans = [0,0,0,0]
for _ in range(N):
    a = input()
    if a == 'AC':
        ans[0] += 1
    elif a == 'WA':
        ans[1] += 1
    elif a == 'TLE':
        ans[2] += 1
    elif a == 'RE':
        a[3] += 1
print('AC ×',ans[0])
print('WA ×',ans[1])
print('TLE ×',ans[2])
print('RE ×',ans[3])


### FIXED CODE ###

N = int(input())
ans = [0,0,0,0]
for _ in range(N):
    a = input()
    if a == 'AC':
        ans[0] += 1
    elif a == 'WA':
        ans[1] += 1
    elif a == 'TLE':
        ans[2] += 1
    elif a == 'RE':
        ans[3] += 1
print('AC x',ans[0])
print('WA x',ans[1])
print('TLE x',ans[2])
print('RE x',ans[3])
n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = L.count(i)
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]-1]-1)*(dn[L[i]-2])/2))

### FIXED CODE ###

n = int(input())
L = [int(i) for i in input().split()]
t = set(L)
dn = {}
dc = {}
All = 0
for i in t:
  dn[i] = 0
for i in L:
  dn[i] += 1
for i in t:
  dc[i] = int(dn[i]*(dn[i]-1)/2)
  All += dc[i]
for i in range(n):
  print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))
x = int(input())
ans = 8 - (X - 400) // 200
print(ans)


### FIXED CODE ###

x = int(input())
ans = 8 - (x - 400) // 200
print(ans)
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    b,c = map(int,input().split())
    BC.append([b,c])
BC.sort(key=lambda x:x[1], reverse=True)
# print(BC)

A.sort()

i = 0
j = 0
while BC[j][1] > A[i] and i < N and j < M:
    if BC[j][0] < 1:
        j += 1
        continue
    A[i] = BC[j][1]
    BC[j][0] -= 1
    i += 1

print(sum(A))

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    b,c = map(int,input().split())
    BC.append([b,c])
BC.sort(key=lambda x:x[1], reverse=True)
# print(BC)

A.sort()

i = 0
j = 0
while i < N and j < M and BC[j][1] > A[i]:
    if BC[j][0] < 1:
        j += 1
        continue
    A[i] = BC[j][1]
    BC[j][0] -= 1
    i += 1

print(sum(A))
import numpy as np

def main(zz=0):
  # Worst Case
  #n,k=100000,100
  #a=[p for p in range(100000)]
  
  kl=[p for p in range(1,k+1)]
  dp=[10**9]*(n)
  dp[0]=0
  for i in range(n):
    for j in kl:
      ij=i+j
      if ij < n:
        m=dp[i]+abs(a[i]-a[ij])
        if m < dp[ij]:
          dp[ij]=m
  print(dp[n-1])

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main','(i4,)')(main)
    cc.compile()

    
if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import main
    n,k=map(int,input().split())
    a=np.array(list(map(int,input().split())))
    main(0)


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
#n,k=100000,100
#a=[i for i in range(100000)]

kl=[i for i in range(1,k+1)]

dp=[float("inf")]*(n)
dp[0]=0
for i in range(1,n):
  dp[i] = min(dp[j] + abs(a[i] - a[j]) for j in range(max(0, i - k), i))

print(dp[n-1])
from UnionFind import UnionFind

N, M = map(int, input().split())

edges = []
for _ in range(M):
    a, b = map(int, input().split())
    edges.append([a-1, b-1])

mat = [[0]*N for _ in range(N)]
for s, g in edges:
    mat[s][g] = 1
    mat[g][s] = 1

ans = 0

for i in range(M):
    uni = UnionFind(N)

    for j in range(M):
        if i != j:
            uni.union(edges[j][0], edges[j][1])

    if not all(uni.find(0) == uni.find(x) for x in range(N)):
        ans += 1
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b = list(map(int, input().split()))
    edges.append([a-1, b-1])

nodes = [0]*N

mat = [[0]*N for _ in range(N)]

for s, g in edges:
    nodes[s] += 1
    nodes[g] += 1
    mat[s][g] = 1
    mat[g][s] = 1

ans = 0


def check(nodes):
    return all(n != 1 for n in nodes)


ans = 0
while not check(nodes):
    for i in range(N):
        if nodes[i] == 1:
            for j in range(N):
                if mat[i][j]:
                    mat[i][j] = 0
                    mat[j][i] = 0
                    ans += 1
                    nodes[i] -= 1
                    nodes[j] -= 1
                    break
print(ans)
#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))
 
Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * (W + 1) for i in range(N)]
 
for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if (i == 0) & (Current_Weight <= W) :
        dp[i][Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        ##まずは前回値を入れる
        for l in range(len(Last_Search_List)):
            Last_Search_Weight =  Last_Search_List[l] 
            dp[i][Last_Search_Weight] = dp[i-1][Last_Search_Weight]
        ##今回値と比べる
        for k in range(len(Current_Search_List)):
            Last_Search_Weight =  Last_Search_List[k] 
            Current_Search_Weight = Current_Search_List[k]
            if Current_Search_Weight > W:
                break
            else:
                dp[i][Current_Search_Weight] = max((dp[i-1][Last_Search_Weight] + Current_Value),
                                                   dp[i-1][Current_Search_Weight])
 
 
print(max(dp[N-1]))

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_e
import copy
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))
 
Sum_Value = sum(map(lambda x:x[1],Goods_List))
dp = [[0] * (Sum_Value + 1) for i in range(N)]

for i in range(N):
    if i == 0:
        dp[i][Goods_List[i][1]] = Goods_List[i][0]
    else:
        dp[i] = copy.copy(dp[i-1])
        Valid_List = [k for k, x in enumerate(dp[i]) if x != 0]
        Valid_List.append(0)
        for j in Valid_List:
            if dp[i][j + Goods_List[i][1]] == 0:
                dp[i][j + Goods_List[i][1]] = dp[i-1][j] + Goods_List[i][0]
            else:
                dp[i][j + Goods_List[i][1]] = min(dp[i-1][j] + Goods_List[i][0],dp[i][j + Goods_List[i][1]])
        

for k in range(len(dp[-1])-1,0,-1):
    if (dp[-1][k] != 0) & (dp[-1][k] <= W):
        print(k)
        break
N = int(input())
A = list(map(input().split()))
count=0
for i in range(N):
  try:
    a=A[i]
    b=A[i+1]
    while a>b:
      b+=1
      count+=1
  except:
    pass
print(count)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
count=0
for i in range(N):
  try:
    a = A[i]
    b = A[i+1]
    if a <= b:
      pass
    else:
      c = abs(a-b)
      A[i+1] = b+c
      count+=c
  except:
    pass
print(count)
n = int(input())
if n == 1000000000000000000:
    print(124999999999999995)
else:
    cnt = 0
    dp = [0]*(n+1)
    dp[0] = 1
    dp[1] = 1
    for i in range(2,n+1):
        dp[i] = i*dp[i-2]
    ans = dp[n]
    l = -1
    while str(ans)[l] == '0':
        cnt+=1
        l-=1
    print(cnt)



### FIXED CODE ###

import sys
n = int(input())
if n%2 == 1:
    print(0)
    sys.exit()
ans = 0
num = 10
while num<=n:
    ans += n//num
    num *= 5
print(ans)
from collections import deque
N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

chil = [[] for _ in range(N+1)]
count = [0]*(N+1)

for ab in AB:
    chil[ab[0]].append(ab[1])
    chil[ab[1]].append(ab[0])

def cleanse(fromN, toN):
    chil[toN].remove(fromN)
    if len(chil[toN])==0:  # leaf
        return
    for node in chil[toN]:
        cleanse(toN, node)

for node in chil[1]:
    cleanse(1, node)

def addition(fromN, toN, value):
    count[toN] += value
    if len(chil[toN])==0:
        return
    for node in chil[toN]:
        addition(toN, node, value)

for px in PX:
    count[px[0]] += px[1]
    for node in chil[px[0]]:
        addition(px[0], node, px[1])

print(*count[1:])

### FIXED CODE ###

a = int(input())
s = input()

if a>=3200: print(s)
else: print('red')
N = int(input())
minn=1000
if N <1 or N>10000
	print(' ')
elif N%1000==0:
	print(0)
else:
	for i in range(1000,10001,1000):
		if N<i:
			print(i-N)
			break


### FIXED CODE ###

N = int(input())
minn=1000
if N <1 or N>10000:
	print(' ')
elif N%1000==0:
	print(0)
else:
	for i in range(1000,10001,1000):
		if N<i:
			print(i-N)
			break
n,k=map(int,input().split())
a=list(map(int,input().split()))
town=[1]
cnt=0
loop=0
index=0
while(len(town) <= k):
    town.append(a[town[-1]-1])
    cnt+=1
    index=town.index(town[-1])
    if cnt != index:
        loop = cnt - index
        town.pop(-1)
        break
town2=[]
if k<index:
    print(town[k])
else:
    for i in range(index,len(town)):
        town2.append(town[i])
    print(town2[(k-index)%loop])


### FIXED CODE ###

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

s=[]
ordn=[]
for i in range(n+1):
    ordn.append(-1)

v=1
while(ordn[v] == -1):
    ordn[v]=len(s)
    s.append(v)
    v=a[v-1]

c=len(s)-ordn[v]
l=ordn[v]

if k<l:
    print(s[k])
else:
    k -= l
    k%=c
    print(s[l+k])
if B%A==0:
    print(A+B)
else:
	print(B-A)

### FIXED CODE ###

n=list(map(int,input().split()))
if n[1]%n[0]==0:
    print(n[0]+n[1])
else:
    print(n[1]-n[0])
S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0

if if len(list)==0:
    print(0)
else:
    print(max(list))

### FIXED CODE ###

S = input()
count = 0
list = []

for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    count+=1
  else:
    list.append(count)
    count = 0
list.append(count)

if len(list)==0:
    print('0')
else:
    print(max(list))
a=int(input())
a=a[-1]
if a==3:
  print('bon')
elif a==2 or a==4 or a==5 or a==7 or a==9:
  print('hon')
else:
  print('pon')

### FIXED CODE ###

a=int(input())
b = a % 10
if b==3:
  print("bon")
elif b==2 or b==4 or b==5 or b==7 or b==9:
  print("hon")
else:
  print("pon")
def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = [2]
    for i in range(k-1):
        nxt = []
        for j in range(len(now)):
            test = now[j]
            nxtd = ra[i+1]
            if test % ra[i] == 0:
                mod = test % nxtd
                if (nxtd-mod)%nxtd < ra[i]:
                    for k in range((nxtd-mod)%nxtd, ra[i], nxtd):
                        nxt.append(k+test)

        if not nxt:
            print(-1)
            exit()
        now = nxt
    now = sorted(list(now))
    ans = []
    for i in now:
        test = i
        if test % ra[-1] == 0:
            ans.append(i)
            ans.append(i+ra[-1]-1)
    ans = sorted(ans)
    print("{} {}".format(ans[0], ans[-1]))
resolve()

### FIXED CODE ###

def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()
H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append([0 if e == '.' else 1 for e in list(input())])

xx = [-1, 0, 1, 0]
yy = [0, -1, 0, 1]


def isValidTransition(x, y, H, W):
    return 0 <= x and x < W and 0 <= y and y < H

def dfs(x, y):
    graph[x][y] = 0
    flag = False
    for idx in range(4):
        nx, ny = x + xx[idx], y + yy[idx]
        if isValidTransition(nx, ny, H, W) and graph[nx][ny] == 1:
            dfs(nx, ny)
            flag = True
    return flag

res = True

for i in range(W):
    for j in range(i, H):
        if graph[i][j] == 1 and not dfs(i, j):
            res = False
            break
    if not res:
        break

print('Yes' if res else 'No')

### FIXED CODE ###

H, W = map(int, input().split())
graph = []
for _ in range(H):
    graph.append(list(input()))

res = True

for j in range(1, W-1):
    for i in range(1, H-1):
        if graph[i][j] == '#' and graph[i + 1][j] == '.' and graph[i - 1][j] == '.' and graph[i][j + 1] == '.' and graph[i][j - 1] == '.':
            print('No')
            exit()
print('Yes')
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

red = np.bitwise_xor.reduce(A)
blue = red^xor
answer = red + blue
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=np.int64)

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

if len(A) > 0:
	red = np.bitwise_xor.reduce(A)
else:
    red = 0
blue = red^xor
answer = red + blue
print(answer)
import collections
n,x,m=map(int,input().split())
if n==1:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)


### FIXED CODE ###

import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    s = s_input()
    k = i_input()
    if k == 1:
        print(s[0])
    else:
        for i in range(k-1):
            if i == len(s)-1:
                break
            if s[i] != "1":
                print(s[i])
                exit()
        print(s[k-1])

if __name__=="__main__":
    main()


### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
K = int(input())

for i in range(K):
	if S[i] == '1':
		continue
	else:
		print(S[i])
		sys.exit()

print(S[K-1])
alphabet = {1:"a",2:"b"}
backet = [0]*26
S = input()
for char in S:
    backet[ord(char)-97] = 1
print(chr(backet.index(0)+97))


### FIXED CODE ###

alphabet = {1:"a",2:"b"}
backet = [0]*26
S = input()
for char in S:
    backet[ord(char)-97] = 1
if backet == [1]*26:
    print("None")
else:
    print(chr(backet.index(0)+97))
n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I:
    c+=1
  else:
    c-=1
    ans = max(c, ans)
print(ans

### FIXED CODE ###

n = int(input())
s = input()
x = 0
ans = 0
for i in s:
  if i=="I":
    x+=1
    ans = max(x, ans)
  else:
    x-=1
print(ans)
v = list(map(int, input().split()))
c = list(map(int, input().split()))
n = int(input())
s = 0
for i in range(n):
  if v[i] - c[i] > 0:
    s += v[i] - c[i]
  else:
    continue
print(s)



### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
for i in range(n):
  if v[i] - c[i] >= 0:
    s += v[i] - c[i]
  else:
    continue
print(s)
n=int(input())
L=[]
for i in [1,...,9]:
    for j in [1,...,9]:
        L.append(i*j)

if n in L:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=int(input())
L=[]
for i in range(1,10):
    for j in range(1,10):
        L.append(i*j)

if n in L:
    print("Yes")
else:
    print("No")
while True:
    inp = input()
    x, y = (int(inp[0]), int(inp[2]))
    op = inp[1]
    if op == '?':
        break
    else:
        if op == '+':
            print(x + y)
        elif op == '-':
            print(x - y)
        elif op == '*':
            print(x * y)
        elif op == '/':
            print(x // y)



### FIXED CODE ###

while True:
    inp = input().split()
    x, y = (int(inp[0]), int(inp[2]))
    op = inp[1]
    if op == '?':
        break
    else:
        if op == '+':
            print(x + y)
        elif op == '-':
            print(x - y)
        elif op == '*':
            print(x * y)
        elif op == '/':
            print(x // y)
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print(B)
else:
  print(A)

### FIXED CODE ###

x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print('B')
else:
  print('A')
N = int(Input())
print(N%1000)

### FIXED CODE ###

N = int(input())
for i in range(1,11):
  if i*1000 >= N:
    print(i*1000-N)
    exit()