s=eval(input())

k=int(eval(input()))

if sum(list(map(int, s[:k]))) == len(s[:k]):

    print((1))

    exit()



for si in s:

    if si!='1':

        break



print(si)

s=eval(input())

k=int(eval(input()))

if len(s) >= k and sum(list(map(int, s[:k]))) == len(s[:k]):

    print((1))

    exit()

for si in s:

    if int(si) > 1:

        print(si)

        exit()
s = eval(input())
k = int(eval(input()))
if sum(list(map(int, s[:k]))) == len(s[:k]):
    print((1))
    exit()
for si in s:
    if si != "1":
        break
print(si)

s = eval(input())
k = int(eval(input()))
if len(s) >= k and sum(list(map(int, s[:k]))) == len(s[:k]):
    print((1))
    exit()
for si in s:
    if int(si) > 1:
        print(si)
        exit()

-if sum(list(map(int, s[:k]))) == len(s[:k]): +if len(s) >= k and sum(list(map(int, s[:k]))) == len(s[:k]): -    if si != "1": -        break -print(si) +    if int(si) > 1: +        print(si) +        exit()