Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:
 - Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.
For example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.
You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?

-----Constraints-----
 - S is a string of length between 1 and 100 (inclusive).
 - K is an integer between 1 and 10^{18} (inclusive).
 - The length of the string after 5 \times 10^{15} days is at least K.

-----Input-----
Input is given from Standard Input in the following format:
S
K

-----Output-----
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.

-----Sample Input-----
1214
4

-----Sample Output-----
2

The string S changes as follows:  
 - Now: 1214
 - After one day: 12214444
 - After two days: 1222214444444444444444
 - After three days: 12222222214444444444444444444444444444444444444444444444444444444444444444
The first five characters in the string after 5 \times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.

Difficulty: EASY

Solutions:
s = input()
k = int(input())
ans = s[0]
for i in range(0, k):
	if s[i] != '1':
		ans = s[i]
		break
print(ans)


s = str(input())
k = int(input())
if s[:k].count('1') == len(s[:k]):
	print(1)
else:
	for i in s:
		if i != '1':
			print(i)
			break


S = input()
K = int(input())
a = 1
for i in range(min(len(S), K)):
	if S[i] != '1':
		a = int(S[i])
		break
print(a)


s = input()
k = int(input())
for i in range(k):
	if s[i] != '1':
		print(s[i])
		exit()
print('1')


s = input()
k = int(input())
for i in range(len(s)):
	n = int(s[i])
	if i + 1 == k:
		print(n)
		break
	elif n != 1:
		print(n)
		break


s = input()
k = int(input())
ans = 1
if len(s) == 1:
	ans = s
else:
	for i in range(k):
		if s[i] != '1':
			ans = s[i]
			break
print(ans)


S = input()
K = int(input())
for i in range(K):
	if S[i] != '1':
		print(int(S[i]))
		break
else:
	print(1)


s = input()
k = int(input())
ans = 1
for v in range(k):
	if s[v] != '1':
		ans = s[v]
		break
print(ans)


S = input()
K = int(input())
if len(S) == 1:
	print(S)
else:
	flg = False
	while S[0] == '1':
		S = S[1:]
		K -= 1
		if K == 0:
			print(1)
			flg = True
			break
	if not flg:
		if S[0] == '2':
			if K.bit_length() - 1 >= 5000000000000000:
				print(S[1])
			else:
				print(S[0])
		else:
			print(S[0])


n = input()
k = int(input())
for i in range(k):
	if n[i] != '1':
		print(n[i])
		break
else:
	print(1)


S = input()
K = int(input())
i = 0
while i < len(S) and S[i] == '1':
	i += 1
if i >= K:
	print(1)
else:
	print(S[i])


s = list(map(str, input().rstrip()))
k = int(input())
ans = 1
for x in s[:k]:
	if int(x) != 1:
		ans = int(x)
		break
print(ans)


s = list(input())
k = int(input())
num_list = [int(i) for i in s]
ans = 1
for i in range(k):
	if num_list[i] != 1:
		ans = num_list[i]
		break
print(ans)


s = input()
for i in range(int(input())):
	if s[i] != '1':
		print(s[i])
		break
else:
	print(1)


def number_count(string, n):
	count = 0
	for i in range(len(string)):
		if int(string[i]) == n:
			count += 1
	return count

def main():
	s = str(input())
	k = int(input())
	if number_count(s, 1) == len(s):
		number = '1'
	else:
		for i in range(len(s)):
			if s[i] != '1':
				first_index = i
				break
		if k < first_index + 1:
			number = '1'
		else:
			number = s[first_index]
	print(number)

def __starting_point():
	main()
__starting_point()


import sys
S = input()
K = int(input())
for i in range(K):
	if S[i] != '1':
		print(S[i])
		sys.exit()
print(1)


def main():
	S = list(input())
	K = int(input())
	for i in range(min(K, len(S))):
		if S[i] != '1':
			print(S[i])
			return
	print('1')
	return

def __starting_point():
	main()
__starting_point()


s = input()
k = int(input())
for i in range(k):
	out = s[i]
	if s[i] != '1':
		break
print(out)


s = input()
k = int(input())
for c in s[:k]:
	if c != '1':
		print(c)
		exit()
print(1)


def main():
	S = input()
	K = int(input())
	cnt = 0
	n = 0
	for i in S:
		if i == '1':
			cnt += 1
		else:
			n = int(i)
			break
	if cnt >= K:
		print(1)
	else:
		print(n)
	return
main()


S = input()
K = int(input())
ones = 0
inf = None
for c in S:
	if c == '1':
		ones += 1
	else:
		inf = c
		break
if K <= ones:
	print('1')
else:
	print(inf)


S = input()
K = int(input())
while S[0] == '1' and len(S) > 1 and (K > 1):
	S = S[1:]
	K -= 1
print(S[0])


S = input()
K = int(input())
count = 0
if S[0] != '1':
	print(S[0])
	return
for i in range(len(S)):
	if S[i] == '1':
		count += 1
	else:
		break
if count >= K:
	print(1)
else:
	print(S[count])


print(input()[:int(input())].replace('1', '')[:1] or 1)


S = [int(i) for i in input()]
K = int(input())
if sum(S) == len(S):
	print(1)
else:
	for i in range(len(S)):
		if S[i] != 1:
			print(S[i])
			break
		elif S[i] == 1 and K - 1 <= i:
			print(1)
			break


S = input()
K = int(input())
ans = 1
for i in range(len(S)):
	if int(S[i]) > 1 and i < K:
		ans = int(S[i])
		break
print(ans)


s = input()
k = int(input())
c = 0
for i in s:
	if i == '1':
		c += 1
	else:
		break
print(s[c] if k > c else '1')


s = input()
k = int(input())
a = '1'
for i in range(min(k, 100)):
	if s[i] != '1':
		a = s[i]
		break
print(a)


import re
print((lambda s: '1' if len(s) - 1 >= int(input()) else s[-1])(re.match('^1*[2-9]?', input()).group()))


s = list(input())
K = int(input())
ANS = 1
for i in range(K):
	if s[i] != '1':
		ANS = int(s[i])
		break
print(ANS)


def main():
	s = input()
	k = int(input())
	for i in s[:k]:
		if i != '1':
			print(i)
			return
	print('1')
main()


S = str(input())
N = int(input())
Ones = 0
nxt = ''
for i in range(len(S)):
	if S[i] == '1':
		Ones += 1
	else:
		nxt = S[i]
		break
if N <= Ones:
	print(1)
else:
	print(nxt)


S = list(input())
K = int(input())
ref = 0
for i in range(len(S)):
	if S[i] == '1':
		ref += 1
	else:
		break
ans = ''
if ref == 0:
	ans = S[0]
elif ref >= K:
	ans = '1'
else:
	ans = S[ref]
print(ans)


S = input().strip()
k = int(input())
for (i, c) in enumerate(S, 1):
	if c != '1' or i == k:
		break
print(c)


s = input()[:int(input())].replace('1', '')
print(1 if s == '' else s[0])


S = input()
K = int(input())
one = 0
for s in S:
	if s == '1':
		one += 1
	else:
		ans = s
		break
if K <= one:
	print(1)
else:
	print(ans)


s = input()
k = int(input())
ans = '1'
for a in s[:k]:
	if a != '1':
		ans = a
		break
print(ans)


S = input()
K = int(input())
for c in S:
	K -= 1
	if K == 0:
		print(c)
		break
	if c != '1':
		print(c)
		break


s = list(map(int, input()))
k = int(input())
for i in range(k):
	if s[i] != 1:
		ans = s[i]
		break
	else:
		ans = 1
print(ans)


S = input()
K = int(input())
for (i, s) in enumerate(S):
	if s != '1':
		break
if K <= i:
	print(1)
else:
	print(S[i])


S = input()
K = int(input())
one = 0
for i in range(len(S)):
	if S[i] == '1':
		one += 1
	else:
		break
if K <= one:
	print('1')
else:
	print(S[one])


S = input()
K = int(input())
OK = True
for i in range(min(K, len(S))):
	if S[i] != '1':
		OK = False
if OK:
	print('1')
	return
for i in range(len(S)):
	if S[i] != '1':
		print(S[i])
		return


S = input()
K = int(input())
for k in range(K):
	if S[k] != '1':
		print(S[k])
		exit()
print(1)


s = input()
k = int(input())
for (i, c) in enumerate(s):
	if c != '1' or i >= k - 1:
		break
print(c)


s = input()
k = int(input())
for i in s[:k]:
	if i == '1':
		continue
	else:
		print(i)
		exit()
print('1')


s = input()
k = int(input()) - 1
for i in range(len(s)):
	if s[i] != '1' or i == k:
		break
print(s[i])


s = input()
k = int(input())
n = 5000 * 10 ** 12
for (i, c) in enumerate(s):
	if c != '1':
		print(c)
		break
	if i + 1 == k:
		print(1)
		break


s = input()
k = int(input())
if len(s) >= k:
	if s[:k] == '1' * k:
		print(1)
		exit()
print(s.replace('1', '')[0])


s = input()
k = int(input())
if k == 1:
	print(int(s[0]))
elif s[0] == '1':
	cnt = 0
	while cnt < len(s) and s[cnt] == '1':
		cnt += 1
	if cnt >= k:
		print(1)
	elif cnt == len(s):
		print('1')
	else:
		print(s[cnt])
else:
	print(int(s[0]))


s = list(input())
k = int(input())
cnt = 0
ans = 0
for i in s:
	if int(i) == 1:
		cnt += 1
		continue
	else:
		ans += int(i)
		break
if k <= cnt:
	print(1)
else:
	print(ans)


S = input()
K = int(input())
if K < 110 and S[:K] == '1' * K:
	print(1)
else:
	print(S.replace('1', '')[0])


S = str(input())
K = int(input())
for i in range(0, K):
	if S[i] != '1':
		print(S[i])
		exit()
print(1)


S = str(input())
K = int(input())
for i in range(K):
	if S[i] != '1':
		print(S[i])
		return
print('1')


S = input()
K = int(input())
c = 0
a = '1'
while c < K:
	if S[c] != a:
		a = S[c]
		break
	c += 1
print(a)


s = list(input())
k = int(input())
for i in range(k):
	s_ = s[i]
	if not s_ == '1':
		print(s_)
		exit()
print('1')


S = input()
K = int(input())
i = 0
while i < K:
	if S[i] != '1':
		print(S[i])
		exit()
	i += 1
print(1)


S = input()
K = int(input())
for k in range(K):
	if int(S[k]) != 1:
		break
print(S[k])


s = list(input())
s = list(map(int, s))
k = int(input())
for _ in s[:k]:
	if _ != 1:
		print(_)
		return
print(1)


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


S = input()
K = int(input())
i = 0
for s in S:
	if s == '1':
		i += 1
	else:
		print(s)
		exit()
	if K <= i:
		break
print(1)


S = input()
k = int(input())
for i in range(0, k):
	if S[i] != '1':
		print(S[i])
		break
else:
	print('1')


Ss = input()
K = int(input())
if set(Ss[:K]) == set('1'):
	print(1)
else:
	print(Ss.replace('1', '')[0])


S = input()
K = int(input())
for i in range(K):
	if not S[i] == '1':
		print(S[i])
		exit()
print('1')


S = input()
K = int(input())

def main():
	cnt = 1
	for i in S:
		if i == '1':
			if K == cnt:
				return '1'
			else:
				cnt += 1
				continue
		else:
			return i
		return '1'
print(int(main()))


N = input()
K = int(input())
ans = '1'
for i in range(K):
	if i >= len(N):
		break
	if N[i] != '1':
		ans = N[i]
		break
print(ans)


import sys
s = input()
k = int(input())
s = list(s)
c = 0
for i in range(len(s)):
	if s[i] == '1':
		c += 1
if c == len(s):
	print('1')
	return
d = 0
if len(s) >= k:
	for i in range(k):
		if s[i] == '1':
			d += 1
if d == k:
	print('1')
	return
for i in range(len(s)):
	if s[i] != '1':
		print(s[i])
		return


a = input()
b = int(input())
c = 1
if a[0] != '1':
	print(a[0])
if a[0] == '1':
	for i in range(len(a) - 1):
		if a[i] == '1' and a[i + 1] == '1':
			c = c + 1
		else:
			break
	if c >= b:
		print(1)
	else:
		print(a[c])


S = input()
K = int(input())
a = 0
for j in S:
	a = a + 1
	if j != '1':
		print(j)
		break
	if a == K:
		print('1')
		break


import sys
S = sys.stdin.readline().strip()
K = int(sys.stdin.readline())
for s_i in S:
	if s_i == '1':
		K -= 1
	else:
		break
	if K <= 0:
		break
print(s_i)


S = input()
K = int(input())
print(S[:K].replace('1', '')[:1] or '1')


S = input()
K = int(input())
N = len(S)
i = 0
while i < K:
	if S[i] == '1':
		i += 1
	else:
		print(S[i])
		exit()
print(1)


S = input()
K = int(input())
for (i, c) in enumerate(S):
	if c != '1':
		break
print(1 if c == '1' or K < i + 1 else c)


S = input()
K = int(input())
for i in range(K):
	if S[i] == '1':
		continue
	print(S[i])
	exit()
else:
	print(1)


s = input()
k = int(input())
i = 0
while True:
	if s[i] == '1':
		if k <= i + 1:
			print('1')
			break
		else:
			i += 1
	else:
		print(s[i])
		break


s = input()
k = int(input())
if k == 1:
	print(s[0])
else:
	for i in range(len(s)):
		if s[i] != '1':
			print(s[i])
			break
		elif i + 1 == k:
			print(s[i])
			break


s_list = list(input())
k = int(input())
for s in s_list[:k]:
	if s != '1':
		print(s)
		exit()
print(1)


s = input()
k = int(input())
cnt = 0
for j in range(len(s)):
	cnt += 1
	if s[j] == '1':
		if cnt == k:
			print('1')
			return
	else:
		print(s[j])
		return


s = input()
k = int(input())
cnt = 0
for i in s:
	if int(i) == 1:
		cnt += 1
	if cnt == k or int(i) != 1:
		print(i)
		break


N = list(input())
N = [int(N[i]) for i in range(len(N))]
K = int(input())
if len(N) < K:
	for i in range(len(N)):
		if not N[i] == 1:
			print(N[i])
			break
	else:
		print(1)
else:
	for i in range(K):
		if not N[i] == 1:
			print(N[i])
			break
	else:
		print(1)


S = list(input())
k = int(input())
for s in S[:k]:
	if s != '1':
		print(s)
		exit()
print(1)


(S, K, c) = (input(), int(input()) - 1, 0)
while c < K and S[c] == '1':
	c += 1
print(S[c])


s = input()
s = str(s)
k = int(input())
n = len(s)
for i in range(n):
	if s[i] != '1':
		break
if k <= i:
	print(1)
else:
	print(s[i])


S = input()
K = int(input())
if S[:K].count('1') == K:
	print(1)
	exit()
A = S.lstrip('1')
print(A[0])


S = input().rstrip()
K = int(input())
for s in S[:K]:
	if s != '1':
		print(s)
		exit()
print(1)


S = input()
K = int(input())
ans = '1'
for c in S[:K]:
	if c != '1':
		ans = c
		break
print(ans)


S = input()
K = int(input())
S = list(S)
for j in range(len(S)):
	if S[j] == '1':
		if j == K - 1:
			ans = 1
			break
	else:
		x = [i for i in S if i != '1']
		ans = x[0]
		break
print(ans)


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inpl():
	return list(map(int, input().split()))

def inpl_s():
	return list(input().split())
S = input()
K = int(input())
for i in range(K):
	if S[i] == '1':
		continue
	else:
		print(S[i])
		return
print(S[K - 1])


s = input()
k = int(input())
s1 = 0
sn1 = '0'
for i in range(len(s)):
	if s[i] == '1':
		s1 += 1
	else:
		sn1 = s[i]
		break
ans = '0'
if s1 >= k:
	ans = '1'
else:
	ans = sn1
print(ans)


s = str(input())
k = int(input())
con = 0
for i in s:
	if i == '1':
		con += 1
	else:
		break
if con >= k:
	print(1)
else:
	print(i)


(S, K) = (list(input()), int(input()))
for i in S:
	K -= 1
	if i != '1' or K == 0:
		print(i)
		exit()


s = input()
k = int(input())
ans = '1'
for c in s[:k]:
	if c != '1':
		ans = c
		break
print(ans)


def main():
	S = input()
	K = int(input())
	ans = '1'
	tmp = -1
	for (i, s) in enumerate(S):
		if s != '1':
			ans = s
			break
		else:
			tmp = i
	if K - 1 <= tmp:
		ans = '1'
	print(ans)

def __starting_point():
	main()
__starting_point()


def solve(S, K):
	ans = ''
	for i in range(len(S)):
		if i + 1 == K:
			ans = S[i]
			break
		if S[i] != '1':
			ans = S[i]
			break
	print(ans)

def __starting_point():
	S = input()
	K = int(input())
	solve(S, K)
__starting_point()


S = input()
K = int(input())
for i in range(min(len(S), K)):
	if S[i] != '1':
		print(S[i])
		exit()
print(1)


s = input()
t = int(input())
for i in range(t):
	if s[i] != '1':
		print(s[i])
		exit()
print('1')


s = input()
k = int(input())
for c in s[:min(len(s), k)]:
	if c != '1':
		print(c)
		exit()
print('1')


s = input()
n = int(input())
for i in range(n):
	if s[i] != '1':
		print(s[i])
		exit()
print(1)


s = str(input())
k = int(input())
ans = 1
for i in range(k):
	if s[i] != '1':
		print(s[i])
		return
print(ans)


import sys
S = input()
K = int(input())
for i in range(K):
	if S[i] != '1':
		ans = S[i]
		break
else:
	ans = '1'
print(ans)


s = str(input())
k = int(input())
len_s = len(s)
cnt_1 = 0
for i in range(len_s):
	if s[i] == '1':
		cnt_1 += 1
	else:
		moji = s[i]
		break
if cnt_1 >= k:
	print(1)
else:
	print(s[i])


s = str(input())
ss = [int(i) for i in s]
k = int(input())
if sum(ss) == len(s):
	print('1')
	return
count = 0
while s[count] == '1':
	if k == count + 1:
		print('1')
		return
	count += 1
print(s[count])


N = list(input())
K = int(input())
for i in range(K):
	a = int(N[i])
	if a != 1:
		print(a)
		exit()
print(1)


S = list(input())
K = int(input())
ans = '1'
for i in range(K):
	if S[i] != '1':
		ans = S[i]
		break
print(ans)


a = input()
b = int(input())
for i in range(b):
	if a[i] != '1':
		print(a[i])
		exit(0)
print(1)
exit(0)


s = input()
k = int(input()) - 1
i = 0
while i < k and s[i] == '1':
	i += 1
print(s[i])


s = input()
a = '1'
for i in range(int(input())):
	if s[i] != '1':
		a = s[i]
		break
print(a)


S = input()
K = int(input())
for (i, s) in enumerate(S):
	if s != '1' and i < K:
		print(s)
		return
print(1)


S = input()
K = int(input())
l = 0
for i in range(len(S)):
	if S[i] == '1':
		l += 1
	if l >= K:
		print(S[i])
		return
	if S[i] != '1':
		print(S[i])
		return


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def mod_pow(x, n):
	res = 1
	while n > 0:
		if n & 1:
			res = res * x
			x = x * x
			n >>= 1
	return res

def main():
	S = input().rstrip()
	K = I()
	for i in range(len(S)):
		if int(S[i]) >= 2 or K == 1:
			print(S[i])
			break
		else:
			K -= 1

def __starting_point():
	main()
__starting_point()


import re
m = re.match('\\A(1*)([1-9]*)\\Z', input())
print('1' if len(m.group(1)) >= int(input()) else m.group(2)[0])


s = input()
k = int(input())
cnt = 0
for v in s:
	if v == '1':
		cnt += 1
	else:
		break
	if cnt == k:
		break
print(v)


s = input()
i = 1
while 1:
	if i == len(s) + 1:
		print(1)
		return
	if s[i - 1] != '1':
		t = i
		ans = int(s[i - 1])
		break
	i += 1
if int(input()) < t:
	print(1)
	return
print(ans)


S = input()
K = int(input())
con = 0
for i in S:
	if i == '1':
		con += 1
	else:
		break
if con >= K:
	print(1)
else:
	print(i)


S = input()
K = int(input())
Slist = list(S)
i = 0
while Slist[i] == '1' and K - 1 != i:
	i += 1
ans = S[i]
print(ans)


s = map(int, input())
k = int(input())
for (i, v) in enumerate(s):
	if i + 1 == k or v > 1:
		print(v)
		break


S = str(input())
k = int(input())
for i in range(k):
	if S[i] != '1':
		print(S[i])
		exit()
print('1')


s = input()
k = int(input())
for i in map(int, s[:k]):
	if i != 1:
		print(i)
		break
else:
	print(1)


def main():
	s = input()
	k = int(input())
	ans = 0
	tyou = 500000000000000
	for v in s:
		if v == '1':
			ans += 1
		else:
			ans += tyou ** int(v)
		if ans >= k:
			print(v)
			return

def __starting_point():
	main()
__starting_point()


s = input()
k = int(input())
cnt = 0
for i in s:
	if i == '1':
		cnt += 1
	else:
		x = i
		break
if cnt >= k:
	print(1)
else:
	print(x)


import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	S = ins()
	K = ini()
	ones = 0
	for (i, d) in enumerate(S):
		if d != '1':
			break
		ones += 1
	if K <= ones:
		return '1'
	return S[ones]
print(solve())


S = input()
K = int(input())
if len(S) >= K and S[:K] == '1' * K:
	print('1')
else:
	S = S.replace('1', '')
	print(S[0])


S = input().rstrip()
K = int(input())
for s in S[:K]:
	if s != '1':
		print(s)
		return
print(1)


print(max('1', input()[:int(input())].replace('1', '')[:1]))


s = input()
k = int(input())
for a in s[:k]:
	if a != '1':
		print(a)
		exit()
print('1')


s = list(input())
k = int(input())
for i in range(k):
	if s[i] != '1':
		print(s[i])
		quit()
print(1)


import sys, math
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
s = lines.pop(0)
(k,) = [int(num) for num in lines.pop(0).split(' ')]
days = 5000 * 10 ** 12
for n in s:
	log_k = math.log10(k)
	n = int(n)
	log_n_days = math.log10(n) * days
	if log_k > log_n_days:
		k -= n ** days
	else:
		break
print(n)


(s, k) = open(0)
for (i, c) in enumerate(s):
	if c == '1':
		if i + 1 == int(k):
			break
	else:
		break
print(c)


for i in input()[:int(input())]:
	if i != '1':
		break
print(i)


S = list(input())
K = int(input())
lsS = [int(i) for i in S]
ii = 0
for i in range(len(S)):
	if lsS[i] == 1:
		ii += 1
	else:
		a = lsS[i]
		break
if ii >= K:
	print(1)
else:
	print(a)


try:
	print([i for i in input()[:int(input())] if i != '1'][0])
except:
	print(1)


s = input()
k = int(input())
one_cnt = 0
for i in range(len(s)):
	if s[i] == '1':
		one_cnt += 1
	else:
		break
if k <= one_cnt:
	print(1)
	return
for i in range(len(s)):
	if s[i] != '1':
		print(s[i])
		return


S = input()
K = int(input())
idx = min(K, len(S))
for s in S[:idx]:
	if s != '1':
		print(s)
		break
else:
	print(1)


S = input()
K = int(input())
if S[:K].count('1') == K:
	print('1')
else:
	print(S.replace('1', '')[0])


for (i, n) in enumerate(input()):
	if n != '1':
		break
print(n if i < int(input()) else 1)


S = input()
K = int(input())
for i in range(K):
	if S[i] != '1':
		print(S[i])
		quit()
print('1')


s = input()
k = int(input())
d = 5 * 10 ** 15
for i in s:
	if i == '1':
		k -= 1
	else:
		print(i)
		return
	if k <= 0:
		print(1)
		return


S = list(map(int, input()))
K = int(input())
flag = False
ans = 1
for i in range(K):
	if S[i] != 1:
		flag = True
		ans = S[i]
		break
print(ans)


s = input()
k = int(input())
s_ = s.lstrip('1')
if k <= len(s) - len(s_):
	print(1)
else:
	print(s_[0])


S = input()
K = int(input())
i = 0
ans = 1
while i < K:
	if S[i] != '1':
		ans = S[i]
		break
	i += 1
print(ans)


S = input()
K = int(input()) - 1
p = 0
while '1' == S[p] and K:
	K -= 1
	p += 1
print(S[p])


S = input()
K = int(input())
cnt = 0
for i in range(len(S)):
	if int(S[i]) == 1:
		cnt += 1
	else:
		if cnt >= K:
			print(1)
		else:
			print(int(S[i]))
		return
print(1)


S = input()
K = int(input())
F = 1
for i in range(K):
	if S[i] != '1':
		print(S[i])
		F = 0
		break
if F:
	print(1)


import sys
s = input()
k = int(input())
for n in s[:k]:
	if int(n) > 1:
		print(n)
		sys.exit()
print(1)


s = input()
k = int(input())
c = s.count('1', 0, k)
x = s.replace('1', '')
if len(x) == 0:
	print(1)
elif c == k:
	print(1)
else:
	print(x[0])


S = input()
a = int(input())
List = list(S)
res = 1
for i in range(a):
	if List[i] != '1':
		res = List[i]
		break
print(res)


import sys
input = sys.stdin.readline

def main():
	S = input().rstrip()
	k = int(input())
	for i in range(k):
		if S[i] != '1':
			break
	print(S[i])

def __starting_point():
	main()
__starting_point()


S = input()
N = len(S)
K = int(input())
if S[:min(N, K)] == '1' * min(N, K):
	ans = 1
else:
	for i in range(N):
		if S[i] != '1':
			ans = S[i]
			break
print(ans)


S = list(map(int, input()))
K = int(input())
res = []
for c in S:
	res.append(c)
	if c != 1:
		break
print(res[min(len(res) - 1, K - 1)])


S = input()
K = int(input())
a = ''
n = 0
if len(S) <= K:
	n = len(S)
else:
	n = K
for i in range(n):
	if S[i] == '1':
		a = '1'
		continue
	else:
		a = S[i]
		break
print(a)


s = input()
k = int(input())
if k == 1 or len(s) == 1:
	ans = list(s)[0]
else:
	ans = None
	for (i, j) in enumerate(list(s)):
		if i < k - 1:
			if j != '1':
				ans = j
				break
		elif i == k - 1:
			ans = j
			break
		else:
			continue
print(ans)


s = input()
n = int(input())
l = []
for x in s:
	l.append(x)
	if x != '1':
		break
print(l[min(len(l) - 1, n - 1)])


s = input()
k = int(input())
for k_i in range(k):
	if s[k_i] != '1':
		print(s[k_i])
		exit()
print(1)


n = input()
k = int(input())
for i in range(k):
	if 1 != int(n[i]):
		print(n[i])
		exit(0)
print(1)


S = input()
K = int(input())
i = 0
while i < K - 1 and S[i] == '1':
	i += 1
print(S[i])


s = input()
k = int(input())
for i in range(min(k, len(s))):
	if s[i] != '1':
		print(s[i])
		return
print(1)


s = list(map(int, list(input())))
k = int(input())
i = 0
while s[i] == 1 and k != 1:
	k -= 1
	i += 1
print(s[i])


(s, k, p) = (list(input()), int(input()) - 1, 0)
while s[p] == '1' and k:
	k -= 1
	p += 1
print(s[p])