peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()
k = int(input())
for i, c in enumerate(s):
    if int(c)>1:
        if k<i+1:
            print(1)
        else:
            print(int(c))
        break
else:
    print(1)
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
    exit()
else:
    for i in range(k):
        if int(b[i]) != 1:
            print(b[i])
            exit()
print(1)
s = input()
k = int(input()) - 1


for i in range(len(s)):
    if s[i] != "1" or i == k:
        break

print(s[i])
s=list(input())
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        p=i+1
        pnum=int(s[i])
        break
    p=101

if k<p:
    print(1)
else:
    print(pnum)
S = str(input())
K = int(input())
s = list(S)

i = 0
p = 0
for i in range(len(s)):
    s[i] = int(s[i])
i = 0
while  i < len(s):
    if s[i] == 1:
        p = i + 1
    else:
        q = s[i]
        break
    i = i+1
if K < p + 1:
    print(1)
else:
    print(q)
S=input()
K=int(input())

try:
    if S[0:K] =='1'*K:
        print(1)
    else:
        S=list(S)
        print([i for i in S if i  != '1'][0])
except:
    if S[0:100] =='1'*100:
        print(1)
    else:
        S=list(S)
        print([i for i in S if i  != '1'][0])
s = input()
k = int(input())

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

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    res = 1
    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            res = s[i]
            idx = i + 1
            break

    if k < idx:
        print(1)
    else:
        print(res)


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

i = 0
while(s[i]=='1'):
    K -= 1 
    if K == 0:
        break 
    i += 1 
print(s[i])
s = input()
k = int(input())
if k <= 100:
    if set(s[:k]) == set('1'):
        print(1)
        exit()
for _ in s:
    if _ != '1':
        print(_)
        exit()
def main():
  from itertools import groupby
  s, n = list(input()), int(input())
  f = False
  for k,v in groupby(s):
    if f:
      print(k)
      break
    if k == '1' and len(list(v)) >= n:
      print(1)
      break
    elif k != '1':
      print(k)
      break
    else:
      f = True

if __name__ == '__main__':
  main()
S = input()
k = int(input())
for i, s in enumerate(S, start=1):
    if s != "1":
        print(s)
        break
    if i == k:
        print(1)
        break
S = input()
K = int(input())
one = 0

for s in S:
  if s=="1":
    one+=1
  else:
    ans = s
    break

if K<=one:
  print(1)
else:
  print(ans)
from sys import stdin
input = stdin.readline

# map(int, input().rstrip().split())

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

LINF = int(1e18+7)
S = input().rstrip()
K = int(input().rstrip())

tmp = LINF
ch = '1'
for i in range(len(S)):
  if S[i] != '1':
    tmp = i
    ch = S[i]
    break

if tmp >= K:
  print(1)
else:
  print(ch)
S = input()
K = int(input())

for idx in range(K):
    if S[idx] != "1":
        print(S[idx])
        break
else:
    print("1")
s = list(input())
s = list(map(int,s))
k = int(input())
for _ in s[:k]:
    if _ != 1:
        print(_)
        exit(0)
print(1)
N = input()
K = int(input())
ans = '1'
for i in range(K):
  if i >= len(N):
    break
  if N[i] != '1':
    ans = N[i]
    break
print(ans)
s = input()
k = int(input())
n = len(s)
cnt = 0
for i in range(n):
    if s[i] !="1":
        break
    cnt+=1
if k<=cnt:
    print(1)
else:
    print(s[cnt])
import sys

input = sys.stdin.readline

def main():
    ans = ''
    index = 0
    s = input().rstrip('\n')
    k = int(input())
    for i in range(len(s)):
        if s[i] != '1':
            ans = s[i]
            index = i
            break
    if ans == '' or k < index+1:
        ans = '1'
    print(ans)

if __name__ == '__main__':
    main()
#!/usr/bin/env python3
s = input()
k = int(input())

i = 0
while i < len(s) - 1:
    if i == k - 1:
        print(s[i])
        exit()
    if s[i] == "1":
        i += 1
    else:
        print(s[i])
        exit()
print(s[i])
# ABC106-C

import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

S = LI2()
K = I()

for i in range(K):
    if S[i] != 1:
        print(S[i])
        break
    elif i == K-1 and S[i] == 1:
        print(1)
S = str(input())
K = int(input())

one = 0

for i in range(len(S)):
  if S[i] == "1":
    one += 1
  else:
    notone = S[i]
    break
#print(one,K,notone)
if one >= K:
  print("1")
else:
  print(notone)
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])

K = int(input())

start = 1
loc = 101
for i in range(len(S)):
    if S[i] != 1:
        start = S[i]
        loc = i
        break

if K > 100:
    print(start)
elif K-1 >= loc:
    print(start)
else:
    print(1)
s = input()
k = int(input())
ans = 1
for i in range(k):
    if s[i] != '1':
        ans = s[i]
        break
print(ans)
S=input()
K=int(input())
ans=0
for i in range(len(S)):
  a=int(S[i])
  if a==1:
    ans+=1
  else:
    print(a)
    break
  if ans>=K:
    print(a)
    break
s=input()
k=int(input())
n=min(len(s),k)
ans=1
for i in range(n):
    if s[i]!="1":
        ans=str(s[i])
        break
print(ans)
txt = input()
n = int(input())
for i in range(n):
  if txt[i] != '1':
    print(txt[i])
    break
else:
  print("1")
S = list(map(int,list(input())))
K = int(input())
for i in range(K):
    if S[i] == 1:
        continue
    else:
        print(S[i])
        exit(0)
print(1)
s=input()
k=int(input())
fl=0
t=0
ans='1'
for i in range(len(s)):
  if s[i]=='1' and fl==0:
    t+=1
  else:
    if fl==0:
      ans=s[i]
      fl=1
if t>=k:
  ans='1'
print(ans)
import sys
input = sys.stdin.readline

S=input().strip()
K=int(input().strip())

n = 0
m = 0
for c in S:
    if c != '1':
        m = int(c)
        break
    n += 1
if K <= n:
    print(1)
else:
    print(m)
import sys
s = input()
n = int(input())
cnt = 0
if n == 1:
	print(s[0])
	sys.exit()
for i in s:
	if i == '1':
		cnt += 1
	else:
		break
if n <= cnt:
	print(1)
	sys.exit()
	
for i in s:
	if i != '1':
		print(i)
		sys.exit()
print(1)
s = input()
k = int(input())

ans = 1
for i in range(k):
    if s[i] != '1':
        ans = s[i]
        break
print(ans)
s = input()
k = int(input())
l = len(s)
pos = 0

for i in range(l):
    if s[i] != "1":
        pos = i
        break
if k - 1 < pos:
    print(s[k - 1])
else:
    print(s[pos])
S=input()
K=int(input())

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

i=0
while i<len(S) and i<K:
    if S[i]!="1":
        print(S[i])
        quit()
    i+=1

print(1)
def resolve():
    S = input()
    K = int(input())
    for i in range(K):
        if S[i] != "1":
            print(S[i])
            exit()
    print("1")
resolve()
s = input()
k = int(input())
ans = '1'
for i in range(k):
    if s[i]!= '1':
        ans = s[i]
        break
print(ans)
import sys
input = sys.stdin.readline

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

n = 1
for i in range(min(len(S), K)):
    if S[i] != '1':
        n = int(S[i])
        break
print(n)
import re
s = input()
k = int(input())

if s[0] != '1':
    print(s[0])
    exit()
else:
    pos = re.search(r'1+',s).end()
    if k <= pos:
        print(1)
    else:
        print(s[pos])
def solve(s, k):
    # 2^5000兆 >> 10^18 なので、sのk文字目までに1以外の数字xがあれば、k番目はxになる
    for i in range(min(k, len(s))):
        if s[i] != '1':
            return int(s[i])
    else:
        return 1

_s = input()
_k = int(input())
print(solve(_s, _k))
s = list(map(int, input()))
k = int(input())
res = 1
n = 0
for i in range(len(s)):
    if s[i] != 1:
        res = s[i]
        n = i + 1
        break
if k < n:
    print(1)
else:
    print(res)
S = list(input())
K = int(input())
for i in S:
    if i != "1":
        break
i = S.index(i)
if K <= i:
    print(1)
else:
    print(S[i])
# input
S = input()
K = int(input())

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

if n_num >= K:
    print(1)
else:
    print(S[n_num])
import re
S=str(input())
k=int(input())

if set(S)=={'1'}:
  print(1)
  
else:
  x=re.search(r'[2-9]',S).start()
      
  if S[0]=='1':
    if k<=x:
      print(S[0])
    else:
      print(S[x])     
  else:
    print(S[0])
s = input()
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)
import sys
S=input()
K=int(input())
ans=''
i=0
while True:
    ans=S[i]
    if(K==(i+1)):
        print(ans)
        sys.exit()
    elif(ans=='1'):
        i+=1
    else:
        print(ans)
        sys.exit()
s=input()
k=int(input())
if s=="1"*len(s):
  print(1)
else:
  i=0
  while True:
    if s[i]!="1":
      n=s[i]
      break
    else:
      i+=1
  if k-1<i:
    print(1)
  else:
    print(s[i])
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)
S = list(input())
K = int(input())
for i in range(min(len(S),K)):
    if S[i] != "1":
        print(int(S[i]))
        exit()
print(1)
S = input()
K = int(input())

i = 0
while i<len(S) and S[i]=='1':
    i += 1

if i >= K:
    print(1)
else:
    print(S[i])
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    k = I()
    for i, si in enumerate(s):
        if si != '1':
            print(si)
            sys.exit()
        if i == k-1:
            break
    print(1)

if __name__ == '__main__':
    main()
s=list(input())
k=int(input())
tmp=0
for i in s:
    ans=i
    if ans!="1":
        break
    else:
        tmp+=1
if tmp>=k:
    print("1")
else:
    print(ans)
s=input()
k=int(input())

for i in range(len(s)):
    if s[i]!="1":
        nextone=s[i]
        break
if s.count("1")==len(s):
    print(1)
elif i>=k:
    print(1)
else:
    print(nextone)
s = input()
k = int(input())
if k <= len(s) :
         for i in range(k):
                  if s[i] != "1":
                           print(s[i])
                           exit()
         print("1")
         exit()
for i in range(len(s)):
         if s[i] != "1":
                  print(s[i])
                  exit()
s=input()
k=int(input())
l=0
for i in s:
    if i=="1":
        l+=1
    else:
        break
print("1" if k<=l else s[l])
S,K=list(input()),int(input())
for i in S:
    K-=1
    if i!='1'or K==0:
        print(i)
        exit()
s = input()
k = int(input())
first = len(s)
for i in range(len(s)):
  if s[i] != '1': first = i; break
if s[0] != '1': print(s[0]); exit(0)
print(1) if k <= first else print(s[first])
S = input()
K = int(input())

ans = 1
for i in S:
	if i != '1':
		ans = i
		break
	if K==1:
		ans = i
		break
	K-=1
print(ans)
n = list(input())
k = int(input())
for i in range(min(len(n),k)):
    if n[i] != '1':
        print(n[i])
        exit()
print(1)
s = list(input())
k = int(input())
num_list = [int(i) for i in s]
ans = 1
for i in range(k):
    if num_list[i] != 1:
        ans = num_list[i]
        break
print(ans)
S = input().strip()
K = int(input())
a = "1"
ind = len(S)
for i in range(len(S)):
    if S[i]!="1":
        a = S[i]
        ind = i
        break
if K<=ind:
    print(1)
else:
    print(a)
s=input()
k=int(input())

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

print(ans)
s = input()
k = int(input())
if s == '1' * len(s):
  print(1)
  exit()
for i in range(len(s)):
  if s[i] != '1':
    idx = i
    num = s[i]
    break
if idx >= k:
  print(1)
else:
  print(num)
# solution

data=input()

k=int(input())

for i,c in enumerate(data):
  if c!='1' or i>=k-1:
    break

print(c)
s = input()
k = int(input())
cnt = 0
for i in range(len(s)):
    if s[i] == '1':
        cnt += 1
    else:
        print(s[i])
        exit()
    if cnt >= k:
        print(s[i])
        exit()
S = input()
K = int(input())
ans = 1
onecount = 0
for i in S:
    if i == "1":
        onecount += 1
        continue
    else:
        if onecount >= K:
            ans = 1
        else:
            ans = i
        break
print(ans)
n=input()
k=int(input())

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

# 5 * 10^15
cnt = 0

for i in range(len(S)):
    if int(S[i]) == 1:
        cnt += 1
    else:
        if cnt >= K:
            print(1)
        else:
            print(int(S[i]))
        exit()

print(1)
#!python3

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


def main():
    n = 1
    for s in S:
        if s != '1':
            print(int(s))
            return
        if n == K:
            print(1)
            return
        n += 1


if __name__ == "__main__":
    main()
def main():
    string = input()
    index = int(input())
    for i in range(len(string)):
        if not string[i] == "1":
            if i > index - 1:
                print("1")
            else:
                print(string[i])
            break
    else:
        # string = "11111...111"のとき
        print("1")


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

not_1_idx = -1
not_1_num = 1
for i, c in enumerate(S):
    if c != "1":
        not_1_idx = i
        not_1_num = c
        break
if not_1_idx >= 0:
    print(1) if K < not_1_idx + 1 else print(not_1_num)
else:
    print(not_1_num)
def main():
    S = input()
    K = int(input())
    one_seq = sum([int(c) for c in S[:min([K, len(S)])]])
    if one_seq == min([K, len(S)]):
        print(1)
    else:
        for c in S:
            if c != '1':
                print(c)
                return


if __name__ == '__main__':
    main()
def main():
    s = input()
    k = int(input())
    r = '1'
    for i,v in enumerate(s):
        if v != '1':
            r = v
            break
    if i >= k:
        print(1)
    else:
        print(r)
    
if __name__ == "__main__":
    main()
def main():
    S = input()
    K = int(input())
    ans = "1"
    for i, s in enumerate(S):
        if s == "1":
            continue
        else:
            if i+1 <= K:
                ans = s
            break
    print(ans)


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

if all(s == "1" for s in S[:K]):
    print(1)
else:
    for i in range(len(S)):
        if S[i] != "1":
            print(S[i])
            break
# ABC-106-C
S = input().rstrip()
K = int(input())


for s in S[:K]:
    if s != '1':
        print(s)
        exit()
print(1)
s=input()
k=int(input())
t=0
one=0
for i in s:
  if i=="1":
    one+=1
  else:
    t=i
    break
if k<=one:
  print(1)
else:
  print(t)
s = str(input())
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print("1")
s = input()
n = len(s)
k = int(input())
for i in range(n):
  if s[i] == '1':
    k -= 1
  else:
    k = -1
 
  if k <= 0:
    print(s[i])
    break
S = input()
K = int(input())

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

if "1" not in s[:k]:
	print (s[0])
	exit()
first = "1"
t = 0
for i in range(len(s)):
	if s[i] != "1":
		first = s[i]
		break
	else:
		t += 1
if k <= t:
	print ("1")
else:
	print (first)
s = input()
k = int(input())
count = 0
for i in range(len(s)):
    if s[i] != "1":
        count = i
        break
if k<count+1:
    print("1")
else:
    print(s[count])
n = input()
k = int(input())
ans = 1

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

print(ans)
s=input()
k=int(input())
if s.count('1') == len(s):
  print(1)
else:
  count = 0
  for i in s:
    if i != '1':
      print(i)
      break
    else:
      count+=1
      if count == k:
        print(1)
        break
s=input()
k=int(input())
ans=0
for i in range(k):
    if s[i]!="1":
        ans=int(s[i])
        break
    else:
        ans=1
print(ans)
S = list(map(int, input()))
K = int(input())
count = 0
for a in S:
    if a == 1:
        count += 1
        if count == K:
            print(1)
            exit()
    else:
        print(a)
        exit()
S=input()
K=int(input())
ans=1
for i in range(K):
    if (S[i]!='1'):
        ans=S[i]
        break
print(ans)
S = [int(n) for n in list(input())]
K = int(input())
c = 0
for i in range(len(S)):
	s = S[i]
	if s == 1:
		c += 1
	else:
		k = 0
		while c < K:
			c += k ** s
			k += 1
	if c >= K:
		print(s)
		break
import sys
s=input()
k=int(input())
for i in range(k):
  if s[i]!="1":
    print(s[i])
    sys.exit()
print(1)
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    S = input()
    K = ii()
    for i in range(min(len(S), K)):
        if S[i] != '1':
            print(S[i])
            return
    print(1)

if __name__ == '__main__':
    main()
s = input()
k = int(input())

if s[:k].count('1') == len(s[:k]):
    print(1)
else:
    for c in s:
        if c != '1':
            print(c)
            exit()
s = list(map(int, list(input())))
k = int(input())
ans = 1

if len(s) <= k:
    for i in s:
        if i != 1:
            ans = i
            break
else:
    for i in range(0,k):
        if s[i] != 1:
            ans = s[i]
            break

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

if sum(S)==len(S):
    print(1)
else:
    for i in range(len(S)):
        if S[i]!=1:
            print(S[i])
            break
        elif S[i]==1 and K-1<=i:
            print(1)
            break
s=list(input())
k=int(input())
for i in range(k):
  if s[i]!="1":
    print(s[i])
    break
else:
  print(1)
n_l=list(input())
now=0
N=int(input())
if n_l[:N].count("1") == len(n_l[:N]):
   print(1)
else:
   for i in range(len(n_l)):
      if n_l[i] != "1":
         print(n_l[i])
         exit()
S = input()
K = int(input())
last = "1"
ind = 100
for i,s in enumerate(S):
    if s != "1":
        last = s
        ind = i
        break
if K-1 < ind:
    print("1")
else:
    print(last)
S = list(input())
K = int(input())

for i in range(K):
    if S[i] != "1":
        print(S[i])
        exit()
    if i + 1 == K:
        print(S[i])
        exit()
print("1")
S = input()
K = int(input())
t = -1
for k in range(len(S)):
    t = k
    if S[k] != "1":
        break
if K <= t:
    print(1)
else:
    print(S[t])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
k = int(read())
for ss in s:
    ss = int(ss)
    if ss > 1:
        print(ss)
        break
    else:
        if k > 1:
            k -= 1
        else:
            print(ss)
            break
s=input()
k =int(input())
for i in range(k):
    if s[i] != '1':
        ans = s[i]
        break
    elif i < k-1:
        ans = s[i+1]
    else:
        ans = s[i]
        
print(ans)
s = str(input())
k = int(input())
for i in range(len(s)):
    if s[i] != '1' or k - 1 == i:
        print(s[i])
        exit()
s = list(str(input()))
s = list(map(int, s))
k = int(input())

flag = True
for i in range(min(len(s),k)):
    if s[i] != 1:
        flag = False
    else:
        pass

if flag:
    print(1)
else:
    for i in range(len(s)):
        if s[i] != 1:
            print(s[i])
            break
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
x = 0
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if x+1 > k:
    print(1)
    exit()
else:
    print(n[x])
import sys

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

for s in S[:min(len(S),K)]:
    if s=="1":
        pass
    else:
        print(s)
        sys.exit()
print(1)
def main():
    S = input()
    K = int(input())

    tmp = ''
    count = 0
    for s in S:
        if s == '1':
            count += 1
        else:
            tmp = s
            break

    if count >= K:
        print('1')
    else:
        print(tmp)


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

for s in S[:K]:
    if s != '1':
        print(s)
        break
else:
    print(1)
s = input()
k = int(input())

for i in range(k):
  if s[i] != "1":
    print(s[i])
    break
else:
  print(1)
s = list(map(str, input().rstrip()))
k = int(input())

ans = 1
for x in s[:k]:
    if int(x) != 1:
        ans = int(x)
        break
print(ans)
s = input()
k = int(input())

if k == 1:
    print(int(s[0]))
elif s[0] == "1":
    cnt = 0
    while  cnt < len(s) and s[cnt] == "1" :
        cnt += 1
    if cnt >= k:
        print(1)
    elif cnt == len(s):
        print("1")
    else:
        print(s[cnt])
else:
    print(int(s[0]))
S = input()
K = int(input())
for k in range(K):
    if S[k] != '1':
        print(S[k])
        exit()
print(1)
s=input()
n=len(s)
k=int(input())

index=-1
for i in range(n):
    if s[i]!='1':
        index=i
        break

if index==-1:
    print(1)
else:
    if k<=index:
        print(s[k-1])
    else:
        print(s[index])
import sys
S = input()
K = int(input())

k=0
for s in S:
  s = int(s)
  k += 1
  if not s == 1:
    print(s)
    sys.exit()
  elif k == K:
    print(1)
    sys.exit()
a = input()[:int(input())]
j = set(sorted(set(a), key=a.index)[:2])
j.discard("1")
print(list(j)[0] if j else 1)
S = input()
K = int(input())
ans = 0
for i in range(K):
    if S[i]!="1":
        ans = S[i]
        break
print(1) if ans==0 else print(ans)
n=str(input())
N = int(n)
m=int(input())
cnt = 0
for i in range(m):
    if i >= N:
        break
    if n[i] == "1":
        cnt +=1
    else:
        break
      
    
if cnt == m:
    print(1)
elif cnt == 0:
    print(n[0])
elif  cnt < m:
    print(n[cnt])
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())
for i in range(K):
    if S[i]=="1":
        continue
    else:
        print(S[i])
        exit()
print("1")
s = input()
k = int(input())

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

if s[0] == "1":
    if k <= one_counter:
        res = s[0]
    else:
        res = s[one_counter]
else:
    res = s[0]

print(res)
#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])
s = list(input())
k = int(input())
ans = "1"
cnt = 0
for i in s:
    if i == "1":
        cnt += 1
    elif cnt < k:
        ans = str(i)
        break
print(ans)
s = input()
k = int(input())

for i, x in enumerate(s):
    if x == '1':
        if k == i + 1:
            print(1)
            exit()
    else:
        print(x)
        exit()
s = input()
if set(s[:int(input())])=={'1'}:
  print(1)
else:
  for i in s:
    if int(i) > 1:
      print(int(i))
      break
S = input()
K = int(input())

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

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

for _s in s:
    if _s == "1":
        if k == 1:
            print(1)
            break
        else:
            k -= 1
    else:
        print(_s)
        break
S=input()
K=int(input())
ans="1"
for i in range(K):
    if S[i]!="1":
        ans=S[i]
        break
print(ans)
import sys


def input():
    return sys.stdin.readline().rstrip()


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

    i = 0

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


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


char_sum = 0

for letter in S:
    n = int(letter)
    let_power = 1 if (n == 1) else float('inf')
    if (char_sum + let_power) >= K:
        print(letter)
        break
    else:
        char_sum += let_power