s = eval(input())

k = int(eval(input()))



n = len(s)

if n == 1 or k == 1: print((s[0]))

else:

  for i in range(n):

    if s[i] == "1":

      k -= 1

      if k == 0: 

        print((s[i]))

        break

    else:

      print((s[i]))

      break
s = eval(input())

k = int(eval(input()))



ans = 1

for i in range(len(s)):

  if s[i] == "1":

    k -= 1

    if k == 0: break

  else:

    ans = s[i]

    break

print(ans)
s = eval(input())
k = int(eval(input()))
n = len(s)
if n == 1 or k == 1:
    print((s[0]))
else:
    for i in range(n):
        if s[i] == "1":
            k -= 1
            if k == 0:
                print((s[i]))
                break
        else:
            print((s[i]))
            break

s = eval(input())
k = int(eval(input()))
ans = 1
for i in range(len(s)):
    if s[i] == "1":
        k -= 1
        if k == 0:
            break
    else:
        ans = s[i]
        break
print(ans)

-n = len(s) -if n == 1 or k == 1: -    print((s[0])) -else: -    for i in range(n): -        if s[i] == "1": -            k -= 1 -            if k == 0: -                print((s[i])) -                break -        else: -            print((s[i])) +ans = 1 +for i in range(len(s)): +    if s[i] == "1": +        k -= 1 +        if k == 0: +    else: +        ans = s[i] +        break +print(ans)