s = eval(input())

k = int(eval(input()))

flag = -1

n = len(s)



if n >= k:

	n = k



for i in range(n):

	if flag == -1:

		if s[i] != '1':

			flag = i



if flag == -1:

	print('1')

else:

	print((s[flag]))
s = eval(input())

k = int(eval(input()))

i = 0



while s[i] == "1":

	i += 1

	if i > len(s) - 1:

		break



if k <= len(s) and i >= k:

	print((1))

else:

	print((s[i]))
s = eval(input())
k = int(eval(input()))
flag = -1
n = len(s)
if n >= k:
    n = k
for i in range(n):
    if flag == -1:
        if s[i] != "1":
            flag = i
if flag == -1:
    print("1")
else:
    print((s[flag]))

s = eval(input())
k = int(eval(input()))
i = 0
while s[i] == "1":
    i += 1
    if i > len(s) - 1:
        break
if k <= len(s) and i >= k:
    print((1))
else:
    print((s[i]))

-flag = -1 -n = len(s) -if n >= k: -    n = k -for i in range(n): -    if flag == -1: -        if s[i] != "1": -            flag = i -if flag == -1: -    print("1") +i = 0 +while s[i] == "1": +    i += 1 +    if i > len(s) - 1: +        break +if k <= len(s) and i >= k: +    print((1)) -    print((s[flag])) +    print((s[i]))