s = str(eval(input()))

k = int(eval(input()))



t = 0

  

for i in range(len(s)):

  temp = s[i]

  if temp == '1':

    t += 1

  else:

    break



if t == 0:

  print((s[0]))

else:

  if k <= t:

    print('1')

  else:

    print(temp)

    

 
s = str(eval(input()))

k = int(eval(input()))



cnt = 0

for i in range(len(s)):

    if s[i] == '1':

        cnt += 1

    else:

        c = s[i]

        break



if cnt:

    if cnt >= k:

        print('1')

    else:

        print(c)

else:

    print(c)

s = str(eval(input()))
k = int(eval(input()))
t = 0
for i in range(len(s)):
    temp = s[i]
    if temp == "1":
        t += 1
    else:
        break
if t == 0:
    print((s[0]))
else:
    if k <= t:
        print("1")
    else:
        print(temp)

s = str(eval(input()))
k = int(eval(input()))
cnt = 0
for i in range(len(s)):
    if s[i] == "1":
        cnt += 1
    else:
        c = s[i]
        break
if cnt:
    if cnt >= k:
        print("1")
    else:
        print(c)
else:
    print(c)

-t = 0 +cnt = 0 -    temp = s[i] -    if temp == "1": -        t += 1 +    if s[i] == "1": +        cnt += 1 +        c = s[i] -if t == 0: -    print((s[0])) -else: -    if k <= t: +if cnt: +    if cnt >= k: -        print(temp) +        print(c) +else: +    print(c)