peterverebics/CodeNet_Python_118 huggingface dataset:
from itertools import groupby
n = list(input())
k = int(input())
if n == 1:
    print(1)
    exit()
li = []
for key,v in groupby(n):
    li.append(list(v))

if li[0][0] == "1":
    if len(li[0])>= k:
        print(1)
        exit()

for i in range(len(n)):
    if n[i] != "1":
        print(n[i])
        break
S = input()
K = int(input())
if len(S) >= K and S[K-1] == "1" and len(set(S[:K]))==1:
    print(1)
else:
    print([c for c in S if c != "1"][0])
S=input()
K=int(input())

for i in range(len(S)):
  si=int(S[i])
  if si>1:
    print(si)
    break
  elif i==K-1:
    print(si)
    break
s = input()
k = int(input())
for i in range(k):
  if s[i] != '1':
    print(s[i])
    break
  if i == k-1:
    print(1)
s = str(input())
k = int(input())



num = 1


for i in range(len(s)):
    ind = i+1
    if s[i] != '1':
        num = int(s[i])
        break
        
if k>= ind:
    ans = num
else:
    ans = 1
    
print(ans)
S = input()
K = int(input())
if len(S) == 1:
  print(S)  
else:
  if S[:K].count('1') == K:
    print(1)
  else:
    print(list(filter(lambda x: x!= '1', S))[0])
S = input().strip()
K = int(input())
N = len(S)
ind = N
for i in range(N):
    if S[i]!="1":
        ind = i
        break
if K<=ind:
    print(1)
else:
    print(S[ind])
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    K = int(input())

    for i in range(K-1):
        if S[i] != "1":
            print(S[i])
            exit()
    print(S[K-1])


if __name__ == '__main__':
    main()
S = input()
K = int(input())

if len(S) > K:
    print(S[K-1])
else:
    num = '1'
    for s in S:
        if s != '1':
            num = s
            break
    print(num)
S=input()
a=int(input())
List=list(S)
res = 1
for i in range(a):
  if List[i] != "1":
    res = List[i]
    break
print(res)
s = list(input())
k = int(input())

if s[0] == '1' and len(s) == 1:
  print(1)
  exit()
elif s[0] != '1':
  print(s[0])
  exit()

if k > 100:
  for i in s:
    if i != '1':
      print(i)
      exit()
  print(1)
  
else:
  for i in s[:k]:
    if i != '1':
      print(i)
      exit()
  print(1)
  exit()
s = input()
k = int(input())
if s[0] != "1":
  print(s[0])
  quit()
c = 0
while s[c] == "1":
  c += 1
  if c == len(s):
    print(1)
    quit()
if c < k:
  print(s[c])
else:
  print(s[k-1])
S = list(input())
K = int(input())

cnt = 0
tmp = 0
for i in range(K):
    if S[i] == '1':
        cnt += 1
    else:
        tmp = S[i]
        break
if K <= cnt:
    print(1)
else:
    print(tmp)
s = input()
k = int(input())

ans = 1
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
        

print(ans)
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(1)
else:
	print(b)
s = list(str(input()))
k = int(input())

s = [int(i) for i in s]

for i in range(k):
    if s[i] == 1:
        continue
    else:
        print(s[i])
        exit(0)

print(1)
s = input()
s = [int(i) for i in s]
k = int(input())
if max(s) == 1:
	print(1)
	exit()
c = 0
for i in s:
	if i == 1: c += 1
	else: break
if k <= c:
	print(1)
else:
	for i in s:
		if i > 1:
			print(i)
			exit()
s = input()
k = int(input())

c = s.count('1',0,k)

x = s.replace('1', '')

if len(x)==0:
    print(1)
else:
    if c ==k:
        print(1)
    else:
        print(x[0])
S = input()
K = int(input())
count = 0

if S[0] != '1':
  print(S[0])
  exit()

for i in range(len(S)):
    if S[i] == '1':
      count += 1
    else:
      break

if count >= K:
  print(1)
else:
  print(S[count])
S=input()
K=int(input())

one = True
for i in range(K):
  one = one and S[i]=='1'
  if not one:
    print(S[i])
    break
if one:
  print(1)
s = input()
k = int(input())    
for i in range(k):
    if s[i] != '1':
        print(s[i])
        exit()
else:
    print(1)
S=input()
K=int(input())
for i in range(K):
    if S[i]!='1':
        break
print(S[i])
s = input()
k = int(input())
#5,000,000,000,000,000
count = 5000000000000000

lis = [int(s[i]) for i in range(len(s))]
for l in lis:
    if l == 1:
        if k > 1:
            k -= 1
            continue
        else:
            print(1)
            exit()
    else:
        print(l)
        exit()
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()
    K = int(input())

    all1flg = True
    for i in range(min(len(S), K-1)):
        if S[i]!='1':
            ans = S[i]
            all1flg = False
            break
    if all1flg:
        print(S[K-1])
    else:
        print(ans)

if __name__ == '__main__':
    resolve()
S = input()
K = int(input())

s0 = 0

for s in S:
    if s == '1':
        s0 += 1
        if s0 == K:break
    else: break
print(s)
s = input()+"2"
k = int(input())

for i,j in enumerate(s):
    if j != "1":
        now = i
        break

if s == "1"*len(s):
    print(1)
else:
    if k-1 < now:
        print(1)
    else:
        print(s[now])
s = input()
k = int(input())

for i in range(k):
    if s[i]=='1':
        k-=1
        if k==0:
            print(s[i]);exit()
        continue
    else:
        print(s[i])
        break
S=input()
k=int(input())
if S[0]!="1":
    print(S[0])
else:
    cnt=0
    for i in range(len(S)):
        if S[i]=="1":
            cnt+=1
        else:
            break
    if cnt>=k:
        print(1)
    else:
        print(S[i])
s=input()
n=len(s)
k=int(input())
r='1'
for i in range(n):
    if s[i]!='1':
        if k>i:
            print(s[i])
            exit()
print(1)
s=input()
for i in range(int(input())):
  if s[i]!='1':
    print(s[i])
    break
else:
  print(1)
from collections import deque
S=deque(list(map(int,list(input()))))
K=int(input())
i=0
while S:
    if S[0]==1:
        S.popleft()
        i+=1
    else:
        break
result=1 if K<=i else S[0]
print(result)
s=input()
k=int(input())
for i in range(k):
  if s[i]!='1':
    print(s[i])
    exit()
print('1')
s = list(input())
k = int(input())


for i in range(k):
    #print(int(s[i]))
    if int(s[i]) != 1:
        print(s[i])
        exit()
print(1)
S = input()
K = int(input())

ans = 1
for k in range(K):
  if S[k] != "1":
    ans = S[k]
    break
print(ans)
S = list(input())
K = int(input())

for i in range(K):
    if S[i] != '1':
        ans = S[i]
        break
    else:
        ans = 1
        continue
print(ans)
s=input()
k=int(input())
d=5*10**15
for i in s:
  if i=='1':
    k-=1
  else:
    print(i)
    exit()
  if k<=0:
    print(1)
    exit()
S = input()
K = int(input())
ans = "1"
for i in range(len(S)):
  if i >= K:
    break
  if S[i] != "1":
    ans = S[i]
    break

print(ans)
S = input()
K = int(input())


ret = "1"
cnt = 0
f = True
for x in S:
    if f and x == "1":
        cnt += 1
    else:
        ret = x
        break

if cnt >= K:
    print("1")
else:
    print(ret)
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(s[i])
    break
else:
  print(s[k - 1])
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()
    K = int(input())

    ans = 1
    for k in range(K):
        if S[k] != "1":
            ans = int(S[k])
            break

    print(ans)


if __name__ == "__main__":
    main()
S = list(input())
k = int(input())
for s in S[:k]:
    if s != '1':
        print(s)
        exit()
print(1)
s = list(input())
k = int(input())
 
flag = True

for i in range(k):
  if s[i] != "1":
    print(s[i])
    flag = False
    break

if flag:
  print("1")
s=input()
k=int(input())
for i in range(k):
    if s[i]!="1":
        print(s[i])
        exit()
print("1")
from collections import deque
d = deque(list(input()))
k = int(input())

while len(d)!= 0:
    x = d.popleft()
    if x != '1':
        print(x)
        exit()
    else:
        k -= 1
        if k == 0:
            print(1)
            exit()
S=(input())
s=list(S)
K=int(input())
if K==1:
  print(s[0])
  exit()
for i in range(K):
  key=s[i]
  if key!='1':
    print(key)
    exit()
print(1)
s = input()
k = int(input())
bigint = 1
for i in range(k):
  if s[i]!="1":
    bigint = int(s[i])
    break
print(bigint)
import sys
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        print(s[i])
        sys.exit()
    if s[i]=="1" and i+1==k:
        print(1)
        sys.exit()
s = input()
k = int(input())
cnt = 0
for i in s:
    if (i=="1"):
        cnt += 1
    else:
        break
if (k<=cnt):
    print(1)
else:
    print(s[cnt])
S=input()
K=int(input())

for i in range(len(S)):
    if S[i]=="1":
        pass
    else:
        break

if K<i+1:
    print(1)
else:
    print(S[i])
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] != "1" and i+1 <= k:
        print(s[i])
        exit()

print(1)
s = input()
k = int(input())
for i in range(k):
    if s[i] != "1":
        break
print(s[i])
# ans

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

if S[0:K].count('1') == K:
  print(1)
  exit()
  
for i in range(K):
  if S[i] != '1':
    print(S[i])
    exit()
#!/usr/bin/env python
# coding: utf-8

# In[40]:


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


# In[41]:


min_idx = min((i for i in range(len(S)) if S[i] != "1"), default=-1)

if min_idx > K-1:
    print("1")
else:
    print(S[min_idx])


# In[ ]:
S = input()
K = int(input())
count = 0
for i in range(K):
    if i >= len(S):
        break
    if S[i] == "1":
        count += 1
if count == K:
    print("1")
    exit()

for i in range(len(S)):
    if S[i] != "1":
        ans = S[i]
        break

print(ans)
s = input()
k = int(input())

answer = 1
if len(s) == 1:
  answer = s
else :
  for i in range(k):
    if s[i] != "1":
      answer = s[i]
      break
print(answer)
s = input()
k = int(input())
for c in s:
    if c != "1":
        break

    k -= 1
    if k == 0:
        break
print(c)
S = int(input())
K = int(input())

for i in range(len(str(S))):
    if int(str(S)[i]) == 1:
        if (K-1) == i:
            print(int(str(S)[i]))
            break
        continue
    else:
        print(int(str(S)[i]))
        break
s = input()
k = int(input())

for i in range(max(k, len(s))):
    if s[i] != '1' or i == k - 1:
        print(s[i])
        break
s=input()#1~100時
k=int(input())#sの5*10^16日後の k番目
for i in range(len(s)):
    if s[i]!="1":
        if i+1<=k:
            print(s[i])
            exit()
        else:
            print(1)
            exit()
print(1)
S=input()
K=int(input())
one=0
for i in range(len(S)):
    if S[i]=='1':
        one+=1
    else:
        break
if K<=one:
    print('1')
else:
    print(S[one])
# -*- coding: utf-8 -*-
s = input()
k = int(input())

for i in range(k):
    if s[i] != '1':
        print(s[i])
        exit()
print(1)
S = input()
K = int(input())

count = 0
xString = ''
for i in range(len(S)):
    if S[i] == '1':
        count += 1
    else:
        xString = S[i]
        break

if K <= count:
    print(1)
else:
    print(xString)
S = input()
N = len(S)
K = int(input())

if S[:min(N,K)] == "1" * min(N,K):
    ans = 1
else:
  for i in range(N):
    if S[i] != "1":
      ans = S[i]
      break
      
print(ans)
S = input()
K = int(input())

for k in range(K):
  if int(S[k])!=1:
    break

print(S[k])
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = X()
K = i()

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

print(1)
S = list(input())
K = int(input())
N = len(S)
ans = 1
for i in range(K):
  if S[i] != '1':
    ans = S[i]
    print(ans)
    break
  elif i == K-1:
    ans = S[i]
    print(ans)
    break
S = input()
K = int(input())
i = 0
while S[i] == '1':
  i += 1
  if i == len(S):
    break
if K <= i:
  print(1)
else:
  print(S[i])
s = list(input())
k = int(input())
cnt = 0
for c in s:
    if c != '1':
        ans = c
        break
    cnt += 1
    if cnt == k:
        ans = 1
        break
print(ans)
s = input()
k = int(input())
for i in range(k):
    if s[i]!='1':
        break
print(s[i])
import sys
s = input()
k = int(input())
for i in range(k):
    if s[i] != '1':
        print(s[i])
        sys.exit()
    else:
        continue
print(1)
S=input()
K=float(input())
lis=list(S)
ss=set(lis)

if len(ss)==1:
  print(S[0])
else:
  if K<=len(S):
    check_list=lis[:int(K)]
    check_set=set(check_list)
    if len(check_set)==1:
      print(check_list[0])
    else:
      for num in lis:
        if int(num)!=1:
          print(int(num))
          break            
  else:
    for num in lis:
      if int(num)!=1:
        print(int(num))
        break
s = input()
k = int(input())
cnt = 0
for l in s:
  if l!='1':
    break
  cnt += 1
if cnt>=k:
  print(1)
else:
  print(s[cnt])
S = input()
K = int(input())

if len(S) >= K and S[:K] == "1"*K:
    print(1)
else:
    for S in list(S):
        if S != "1":
            print(S)
            break
S = input()
K = int(input())
if len(S) >= K and S[:K].count("1") == K:
    print(1)
else:
    for c in S:
        if c != "1":
            print(c)
            break
import sys
s = list(input())
k = int(input())
if len(s) == 1:
    print(s[0])
elif k == 1:
    print(s[0])
else:
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            sys.exit()
    print(1)
n = input()
b = int(input())
lenn = len(n)
count = 0
for i in range(lenn):
    if n[i] == "1":
        count += 1
    else:
        break
if count >= b:
    print(1)
else:
    print(n[count])
n=input()
k=int(input())
counter=0
nex=0
for i in range(len(n)):
  if n[i]=='1':
    counter+=1
  else:
    nex=n[i]
    break
if nex==0:
  nex='1'
if k>counter:
  print(nex)
else:
  print(1)
s=(input())
k=int(input())
flag=1
for i in range(k):
    if(s[i]!='1'):
        print(s[i])
        flag=0
        break

if(flag==1):
    print("1")
s = input()
k = int(input())

cnt = 0
for i in range(len(s)):
    if s[i]=="1":
        cnt += 1
    else:
        break

if cnt < k:
    print(s[cnt])
else:
    print(1)
print(max("1",input()[:int(input())].replace("1","")[:1]))
S = input()
K = int(input())

if len(S)>=K and S[:K] == "1"*K:
  print("1")
else:
  S = S.replace("1","")
  print(S[0])
s=input()
k=int(input())
ans=1
for i in range(k):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)
s = str(input())
k = int(input())
flag = False
for i in range(len(s)):
  if s[i] != '1':
    flag = True
    posi = i
    break
if flag:
  if k < posi+1:
    print(1)
  else:
    print(s[posi])
else:
  print(s[0])
s = input()
k = int(input())
n = 5000 * 10**12

for i, c in enumerate(s):
    if c != '1':
        print(c)
        break
    if i + 1 == k:
        print(1)
        break
a=input()
b=int(input())
if b<101:
  if a[:b]=='1'*b:print(1)
  else:
    k=0
    while a[k]=='1':k+=1
    print(a[k])
else:
  k=0
  while a[k]=='1':k+=1
  print(a[k])
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= int(K) :
        print(1);
        break;
s=list(input())
k=int(input())
x=0
ans=0
while x<len(s) and s[x]=="1":
  x+=1
if x>0:
  if k<=x:
    ans=1
  else:
    ans=s[x]
else:
  ans=s[0]

print(ans)
s = input()
k = input()
 
for i in range(len(s)) :
    if s[i] != '1' :
        if int(k) <= i :
            print('1')
            break
        else :
            print(s[i])
            break
    else :
        if i == len(s) - 1 :
            print('1')
S = input()
K = int(input())
c = 0
f = 1
for i in range(len(S)):
    if S[i] == '1':
        c+=1
    else:
        f = S[i]
        break
if K<=c: print(1)
else: print(f)
s = input()
k = int(input())
for i in range(k):
  if s[i] != "1":
    print(s[i])
    break
else:
  print("1")
s=input()
k=int(input())

notone=len(s)
for i in range(len(s)):
    if s[i]!="1":
        notone=i
        break
if notone>=k:
    print(1)
else:
    print(s[notone])
s = input()
k = int(input())
ans = 1

for i in range(min(len(s),k)):
    x = int(s[i])
    if x != 1:
        ans = x
        break
        
print(ans)
s = input()
n = int(input())

i = 0
while i != len(s) and s[i] == '1':
    i += 1

if n <= i:
    print(1)
else:
    print(s[i])
s = input().strip()
k = int(input().strip())
days = 5 * (10 ** 15)
if len(s) == 1:
    print(s)
    exit()
before = 0
for i in range(0, len(s)):
    diff = 0
    if s[i] == "1":
        diff = 1
    else:
        for j in range(1, (days + 1), 1):
            if 10 ** 18 <= int(s[i]) ** j:
                diff = int(s[i]) ** j
                break
    if (k - 1) < (before + diff):
        print(s[i])
        break
    else:
        before = before + diff
S =input()
K = int(input())
if S.count("1") == len(S):
  print(1)
else:
  for i in range(len(S)):
    if S[i] != "1":
      print(S[i])
      break
    elif i+1 == K:
      print(S[i])
      break
S=input()
K=int(input())

for i in range(K):
    if S[i]!='1':
        print(int(S[i]))
        break
else:
    print(1)
S = input()
K = int(input())
for s in S:
    if s != "1":
        print(s)
        exit()
    else:
        K -= 1
        if not K:
            print(1)
            exit()
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

s = input()
k = int(input())
if k == 1:
    print(s[0])
else:
    flag = True
    for i in range(k):
        if s[i] != "1":
            flag = False
            break
    if flag:
        print("1")
    else:
        for i in s:
            if i != "1":
                print(i)
                break
        else:
            print(s[0])
S = input()
K = int(input())

one = 0

for i in S:
    if i != '1':
        c = i
        break
    else:
        one += 1

if K <= one:
    print(1)
else:
    print(c)
S=input()
K=int(input())
S=list(S)

for j in range(len(S)):
    if S[j]=='1':
        if j==K-1:
            ans=1
            break
    else:
        x=[i for i in S if i!='1']
        ans=x[0]
        break

print(ans)
s=list(input())
k=int(input())
ch=0
for i in range(len(s)):
  if s[i]=='1':
    ch+=1
  else:
    ss=s[i]
    break
    
if ch>=k:
  print(1)
else:
  print(str(ss))
S = input()
K = int(input())
for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
print(1)
s = input()
k = int(input())
flag = True

if len(s)==1:
    print(int(s))
    exit()

new = ''
for i in s:
    if i!='1':
        flag = False
        new += i

if flag:
    print(1)
else:
    print(new[0])
S = input()
K = int(input())

if len(S) == 1:
    print(S)
    exit()

answer = S[1]
print(answer)
s = input()
k = int(input())
ans = "1"
for si in s:
    if si!="1":
        ans = si
        break
print(ans)
S = input()
K = int(input())
ans = 0
if S[0] == "1":
  if K == 1:
    print(1)
  else:
    if len(S) == 1:
      print(1)
    else:
      print(S[1])
else:
  print(S[0])
import sys
S = input()
K = int(input())
for i in S:
  if i != 1:
    print(i)
    sys.exit()
print(1)
S = input()
K = int(input())

for s in S:
    if s != '1':
        print(s)
        break
s = list(map(int, list(input())))
k = int(input())

f = True
for i in range(len(s)):
    if s[i] == 1:
        continue
    else:
        print(s[i])
        f = False
        break
if f:
    print(1)
s=input()
k=int(input())
for i in range(len(s)):
	if i+1==k:
		break
		exit()
	if s[i]!="1":
		print(s[i])
		exit()
print(1)
s = list(input())
k = int(input())
number = 0
for i in range(len(s)):
    if s[i] == "1" and i == k - 1:
        print(i + 1)
        exit()
    elif s[i] != "1" and number == 0:
        number = s[i]
print(number)
def main():
  s, k = input(), int(input())
  n = s.find('1') + 1
  	
  if n >= k:
    print(1)
  else:
    print(s[n])

if __name__ == '__main__':
  main()
S = list(input())
K = int(input())
ans = 1

for i in range(len(S)):
    if S[i] != '1' :
        ans = S[i]
        break
print(ans)
S=input()
k=int(input())
if S[0]=='1' and k==1:
    print(1)
else:
    for s in S:
        if s!='1':
            print(s)
            exit()
S = list(input())
K = int(input())

ref = 0
for i in range(len(S)):
    if S[i] == "1":
        ref += 1
    else:
        break

ans = ""
if ref == 0:
    ans = S[0]
else:
    if ref >= K:
        ans = "1"
    else:
        ans = S[1]

print(ans)
S = input()
K = int(input())

if K == 1:
    print(S[0])
elif S[0] == '1':
    print(S[1])
else:
    print(S[0])
S = list(input())
K = int(input())

for s in S:
    if s != '1':
        print(s)
        exit(0)
S = input()
K = int(input())

if len(S) == 1:
    print(S)
    exit()

if K == 1:
    print(S[0])
    exit()

for i in S:
    if i != '1' and K != 1:
        print(i)
        exit()
S = input()
K = int(input())

for s in S[:K+1]:
    if s != "1": 
      print(s)
      break
s = input()
k = int(input())
m = 0
for i in s:
  if i==1:
    m += 1
  else:
    break
if m>=k:
  print(1)
else:
  for i in s:
    if i!=1:
      print(i)
      break
s = str(input())
k = int(input())
i = 0
n = s[0]
m = len(s)
while (i < m):
  if int(s[i]) ** 2 >= k:
    n = s[i]
    break
  else:
    k -= int(s[i])
  i += 1
print(n)
S = list(input())
K = int(input())
for i in range(min(len(S),K)):
    if S[i] != 1:
        print(S[i])
        exit()
print(1)
import sys
S = input()
K = int(input())

if len(S) == 1:
  print(S)
  sys.exit()
 
for i in range(0,K):
    if S[i] == "1":
        pass
    else:
        print(S[i])
        sys.exit()
s = str(input())
k = int(input())
ans = 0
count = 0
for i in s:
    if i == "1":
        count += 1
    else:
        if k <= count:
            print(1)
            break
        else:
            print(i)
            break
S = input()
K = int(input())
ans = ""

if int(S[0]) > 1:
  ans = S[0]
elif K>=100:
  for i in range(len(S)):
    if int(S[i]) > 1:
      ans = S[i]
      break
else:
  for i in range(len(S)):
    if int(S[i]) > 1:
      if i+1 <= K:
        ans = S[i]
        break
      else:
        ans = 1
print(ans)
S = list(input())
K = int(input())

if S.count('1') == len(S):
    print(1)
for s in S:
    if s != '1':
        print(s)
        exit(0)
s=input()
k=int(input())
for i in range(min(len(s),k)):
  if s[i]!="1":
    print(s[i])
    break
print(1)
import sys

s = input()
k = int(input())

for i in range(0, len(s)):
  if s[i] != '1':
    print(s[i])
    sys.exit(0)
print('1')
import sys

S = sys.stdin.readline().strip()
K = int(sys.stdin.readline())

for s_i in S:
    if s_i == "1":
        K -= 1
    else:
        break
print(s_i)
s=input()
k=int(input())
ans=0
for i in range(len(s)):
    if s[i]!=1:
        print(s[i])
        break
    else:
        ans+=1
        if k<ans:
            print(1)
            break
S = list(map(int,list(input())))
K = int(input())
if sum(S[:K]) == K:
    print('1')
else:
    for s in S:
        if s == 1:
            continue
        else:
            print(s)
            break
s = input()
k = int(input())

all1 = True
if len(s) > k:
    for i in range(k):
        if s[i] != '1':
            all1 = False
    if all1:
        print(s[k-1])
        exit()
if s[0] == '1':
    if len(s) == 1:
        print(s[0])
    else:
        print(s[1])
else:
    print(s[0])
s=input()
k=int(input())
for i in s:
  if i=='1':
    k-=1
  else:
    k-=int(i)*(5*(10**15))
  if k<=0:
    print(i)
    exit()
S=input()
K=int(input())
for i in range(10**6):
  if S[i]!=1:
      print(S[i])
      break
def resolve():
	s = input()
	k = int(input())
	if len(s) == 1:
		print(s)
		return

	for i in s:
		if int(i) == 1:
			continue
		print(i)
		return
resolve()
s = int(input())
k = int(input())
 
for i in str(s):
    if i == '1':
        pass
    else:
        print(i)
        break
S=input()
K=int(input())
ans=0
mod=5*(10**15)
for i in range(len(S)):
  a=int(S[i])
  if a==1:
    ans+=1
  else:
    ans+=a*mod
  if ans>=K:
    print(a)
    break
#!/usr/bin/env python3

s = str(int(input()))
k = int(input())

if len(s) == 1:
    print(s)
    exit()


if s[0] == "1":
    print(s[1])
else:
    print(s[0])
s = input()
k = input()

for a in s:
    if a != '1':
        print(int(a))
        exit()

print(1)