s=eval(input())

k=int(eval(input()))

i=0

while i!=k and s[i]=="1":i+=1

if i==k:print((1))

else:print((s[i]))
s=eval(input())

k=int(eval(input()))

ans,bns=0,0

for i in range(len(s)):

    if s[i]!="1":

        ans=s[i]

        break

    else:

        bns+=1 #0の連続

if k<=bns: #k=何番目

    print((1))

else:

    print(ans)
s = eval(input())
k = int(eval(input()))
i = 0
while i != k and s[i] == "1":
    i += 1
if i == k:
    print((1))
else:
    print((s[i]))

s = eval(input())
k = int(eval(input()))
ans, bns = 0, 0
for i in range(len(s)):
    if s[i] != "1":
        ans = s[i]
        break
    else:
        bns += 1  # 0の連続
if k <= bns:  # k=何番目
    print((1))
else:
    print(ans)

-i = 0 -while i != k and s[i] == "1": -    i += 1 -if i == k: +ans, bns = 0, 0 +for i in range(len(s)): +    if s[i] != "1": +        ans = s[i] +        break +    else: +        bns += 1  # 0の連続 +if k <= bns:  # k=何番目 -    print((s[i])) +    print(ans)