Problem:
 ﻿Score: 300 points    Problem Statement  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 1 1214
4      Sample Output 1 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 .       Sample Input 2 3
157      Sample Output 2 3  The initial string is 3 . The string after 5 \times 10^{15} days consists only of 3 .       Sample Input 3 299792458
9460730472580800      Sample Output 3 2

Solution (Python):
S = input()
K = int(input())

for c in S:
    c = int(c)
    if c == 1:
        K -= 1
        if K <= 0:
            print(1)
            break
    else:
        print(c)
        break

Solution (Python):
s = input()
k = int(input())
a = 0
m = float('inf')
for i in s:
    if k <= int(i) ** m + a:
        print(i)
        break
    else:
        a += int(i) ** m

Solution (Python):

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

t = 0
index = 0

const = 5000000000000000
flag = False

for i in range(0,len(S)):
    
    
    if int(S[i]) == 1:
        t += 1
        if K < t:
            index = i
            flag = True
        if flag:
            break
    else:
        for j in range(1,const + 1):
            t2 = int(S[i]) ** j
            if K < t+t2:
                index = i
                flag =True
            if flag:
                break
   
print(S[index])

Solution (Python):
a=input()
k=int(input())
a=list(a)

d=0
for i in range(0,len(a)):
    if a[i]!='1':
        break
    d+=1
if a[0]=='1':
    if k<=d:
        print("1")
    else:
        for i in range(0,len(a)):
            if a[i]!='1':
                print(a[i])
                break
else:
    print(a[0])

Solution (Python):
import sys

str_s = input()
k = input()

int_s = int(str_s)
k = int(k)

gosentyo = 5000000000000000
count = 0




for s in str_s:
    now_count = 1

    if int(s) == 1:
        count += 1
        if count >= k:
            print(s)
            sys.exit()
    else:
        for i in range(gosentyo):
            
            if (now_count + count >= k):
                print(s)
                sys.exit()
            now_count *= int(s)
        else:
            count += now_count

Solution (Python):
S=str(raw_input().strip("\n").strip())
K=int(raw_input())
N=len(S)
pos=0
for x in xrange(N):
    if(S[x]!='1'):
        pos=x
        break
if(pos>K-1): print("%c"%('1'))
else: print("%c"%S[pos])

Solution (Python):
s = input()
k = int(input())
ans = 0
for i in range(0,len(s)):
    if s[i] == "1":
        ans = 1
    if s[i] != "1":
        ans = s[i]
        break
    if i >= k-1:
        break
print(ans)

Solution (Python):


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

S2 = ""
for i in range(len(S)):
    if S[i] == "1":
        S2 += "1"
    else:
        S2 += S[i] * 100
        break

if K <= 100:
    print(S2[K-1])
else:
    print(S2[-1])

Solution (Python):
s = input()
k = int(input())
for i in range(len(s)):
    if s[i] != '1':
        print(s[i])
        exit()
    else:
        if i == len(s) - 1:
            print('1')
            exit()
        if i + 1 == k:
            print('1')
            exit()

Solution (Python):

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

count = 0
while(count < len(S) and S[count] == "1"):
	count += 1

if(K <= count):
	print("1")
else:
	print(S[count])

Solution (Python):
S = input()
K = int(input())

X = 0
for s in S:
    if s == "1":
        X += 1
    else:
        break

if K == 1:
    print(S[0])

elif K <= X:
    print(1)

else:
    for s in S:
        if s != "1":
            print(s)
            break
    else:
        print(1)

Solution (Python):
s = input()
K = int(input())

S = list(s)
answer = []

for i in range(len(S)):
    if S[i] == '1':
        answer.append(S[i])
    else:
        answer.append(S[i])
        break

if K <= len(answer):
    print(answer[K-1])
else:
    print(answer[-1])

Solution (Python):

s=input()
k=int(input())
lists=list(s)
ans=1
for i in range(min(k,len(lists))):
    if not lists[i] == "1":
        ans=lists[i]
        break
print(ans)

Solution (Python):

s=input()
k=int(input())
lists=list(s)
ans=1
for i in range(min(k,len(lists))):
    if not lists[i] == "1":
        ans=lists[i]
        break
print(ans)

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = raw_input()
K = input()

cnt = 0
c1 = ''
for c in S:
    if c == '1':
        cnt += 1
    else:
        c1 = c
        break

if cnt >= K:
    print 1
else:
    print c1

Solution (Python):
S, K = map(int, [input() for i in range(2)])
count = 0
a = 0

for i in str(S):
    if int(i) == 1:
        count += 1
        continue
    else:
        a = int(i)
        break

if count >= K:
    print(1)
else:
    print(a)

Solution (Python):
S = input()
K = input()
count = 0
for i in range(len(S)):
    if S[i]=="1":
        count+=1
    else:
        break
        
print(1) if int(K) <= count else print(S[count])

Solution (Python):
def main():
    s = raw_input().strip()
    k = int(raw_input().strip())
    for c in s:
        if k == 1:
            print c
            break
        if c == '1':
            k -= 1
        else:
            print c
            break

if __name__ == '__main__':
    main()

Solution (Python):
S = str(input())
K = int(input())

ans = '1'
count = 0
for s in S:
    if s == '2' or s == '3' or s == '4' or s == '5' or s == '6' or s == '7' or s == '8' or s == '9':
        ans = s
        break
    count += 1
    if count == K:
        break
    
print(ans)

Solution (Python):
S = input()
SS =list(S)
K = int(input())
ans = 1
for i in range(len(S)):
    if SS[i] != '1' and K>=i+1:
        print(SS[i])
        exit()
print(ans)

Solution (Python):
from collections import deque
n = input()
k = int(input())
c = list(n)
d = deque(c)
ans=0
while len(d) > 0:
    a = d.popleft()
    i = int(a)
    if i==1:
        k = k-1
        if k==0:
            ans = 1
            break
    else:
        ans = i
        break


print(ans)

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

Solution (Python):


N=input()
K=int(input())
num=0
count=0
flag=0
for i in N:
  count+=1
  if int(i)!=1:
    num=int(i)
    flag=1
    break
if count>K or flag==0:
  print(1)
else:
  print(num)

Solution (Python):
ss=input()
k=int(input())
s=[int(i) for i in ss ]

j=0
q=0
w=0
while q==0:
    if s[j]==1:
        w+=1
        if k<=w:
            print(1)
            q=1
        j+=1
    else:
        print(s[j])
        q=1

Solution (Python):
s=input()
k=int(input())

a=0
count=0
for i in s:
    if i=="1":
        count+=1
    else:
        a=i
        break
        
if k<=count:
    print(1)
else:
    print(int(a))

Solution (Python):
s = int(input())
k = int(input())

num1=1
ans = 0
for i in range(100):
	a =s//(10**(99-i))
	a -= (a//10)*10
	if a>1:
		ans = a
		break
	num1 +=a
	

if k < num1:
	ans = 1

print(ans)

Solution (Python):
s=input()
k=int(input())

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

Solution (Python):
S = input()
K = int(input())

count = 0
for c in S:
    if (c == '1'):
        count += 1
    else:
        ans = c
        break

if (K <= count):
    print('1')
else:
    print(ans)

Solution (Python):
S=input()
K=int(input())
t=0
for i in range(len(S)):
    if S[i]!="1":
        print(S[i])
        break
    else:
        t+=1
        if t>=K:
            print("1")
            break
        else:
            continue

Solution (Python):
S = input()
K = int(input())
if K == 1:
	print(S[0])
	exit()
else:
	i = 0
	K -= 1
	while S[i] == "1" and K > 0:
		i += 1
		K -= 1
	print(S[i])

Solution (Python):



def main():
    s = input()
    k = int(input())
    one_count = 0

    for si in s:
        if si == '1':
            one_count += 1
        else:
            break

    if s[0] == '1':
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[one_count])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == '__main__':
    main()

Solution (Python):
s = list(map(int,list(input())))
k = int(input())
for item in s:
  if item == 1:
    k -= 1
  else:
    k -= 1000000000000000000
  if k <= 0:
    print(item)
    break

Solution (Python):
S=list(str(int(input())))
K=int(input())

if K!=1 and len(S)!=1 and int(S[0])==1:
    num1 = 0
    for i in S:
        if int(i)==1:
            num1 +=1
        else:
            break
    if K<=num1:
        print(1)
    else:
        print(S[num1])
else:
    print(S[0])

Solution (Python):
s=input()
k=int(input())

for i,c in enumerate(s):
    if c != "1":
        print(c)
        exit()
    elif i+1 == k:
        print("1")
        exit()
print("1")

Solution (Python):
s = str(input())
k = int(input())
result = '1'
result = 1
for i,c in enumerate(s):
    if i == k - 1:
        result = c
        break

    if c == '1':
        pass
    else:
        result = c
        break

print(result)

Solution (Python):
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Solution (Python):
s = input()
k = int(input())

if int(s[0]) == 1:
  one_count = 0
  i = 0
  while i < len(s) and int(s[i]) == 1:
    one_count += 1
    i += 1
  if k <= one_count:
    print(1)
  else:
    print(s[one_count])
else:
  print(s[0])

Solution (Python):
S = list(input())
K = int(input())

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

Solution (Python):
def main():
    s = input().rstrip()
    k = int(input().rstrip())

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

    if k <= cnt:
        print(1)
    else:
        print(s[cnt])
    
    
main()

Solution (Python):
S = input()
K = int(input())

for i in S:
    if i == '1':
        K -= 1
        if K == 0:
            print(1)
            break
    else:
        print(i)
        break

Solution (Python):
import math
N = 5000000000000000
S = input()
K = math.log(int(input()))
for i in S:
  num = int(i)
  if num == 1:
    if num == int(math.exp(K)):
      print(num)
      break
    else:
      K = math.log(int(math.exp(K)-1))
      continue
  kk = N * math.log(num)
  if kk >= K:
    print(num)
    break
  else:
    K -= kk

Solution (Python):
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def count_first_1(s):
    count = 0
    first_letter = ''

    for letter in s:
        if letter == '1':
            count += 1
        else:
            first_letter = letter
            break

    return count, first_letter


if __name__ == "__main__":
    s = S()
    k = I()

    count, first_letter = count_first_1(s)

    if not first_letter:
        result = '1'

    elif count >= k:
        result = '1'

    else:
        result = first_letter

    print(result)

Solution (Python):
s = input()
k = int(input())

if s[0] != "1":
    print(int(s[0]))
else:
    count = 0
    i = 0
    if len(set(s)) == 1:
        print(1)
    else:
        while s[i] == "1":
            count += 1
            i += 1
        if k <= count:
            print(1)
        else:
            print(int(s[i]))

Solution (Python):
S = input()
K = int(input())

for i in range(K):
    if (int(S[i]) == 1):
        ans = int(S[i])
        continue
    if (int(S[i]) >= 2):
        ans = int(S[i])
    break

print(ans)

Solution (Python):
S = input()
K = input()




length_1 = len(S)
K = int(K)

i =int(S)
v_1 = []

while i > 0:
    v_1.append( i % 10 )
    
    i //= 10 
v_1.reverse()

length_n = 0
target_v_num = 0

while length_n < K:
    V = v_1[target_v_num]
    length_n = length_n + 1
    if V > 1:
        length_n = length_n + K
    target_v_num = target_v_num + 1


print(V)

Solution (Python):
import sys
S=list((input()))
K=(input())


if S[0]!='1':
    print(S[0])
    sys.exit()

first_non1=1
count=0
find=0
for i in range (len(S)):
    if S[i]!='1' and find==0:
        first_non1=S[i]
        count=i
        find+=1
        
if int(K)<count+1:
    print(1)
else:
    print(int(first_non1))

Solution (Python):
import math
time = 5 * 10**15

num = list(input())
k = int(input())

chk = 0
count = 0
while chk == 0:
    if num[0] == '1':
        num.pop(0)
        count += 1
        if len(num)==0:
            break
    else:
        chk = 1

if k <= count:
    print(1)
else:
    print(num[0])

Solution (Python):
S=list(input())
K=int(input())
S0=[]
for i in S:
    if i=='1':
        S0.append(i)
    else:
        S0.append(i)
        break
if K>=len(S0):
    print(S0[-1])
else:
    print(S0[K-1])

Solution (Python):
s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=sum
        break

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    nex=int(it)+int(1)
    print(s[it:nex])

Solution (Python):
S=str(input())
K=int(input())
b=0
for i in range(K):
    if S[i]!="1":
        print(S[i])
        b=3
        break

if b!=3:
    print(S[K-1])

Solution (Python):
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])

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

Solution (Python):
import math

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

n1 = 0
first_non1 = 0
for s in S:
    sint = int(s)
    if sint == 1:
        n1 += 1
    else:
        first_non1 = sint
        break


if K <= n1:
    print(1)
else:
    print(first_non1)

Solution (Python):
s = input()
k = int(input())

one = 0
two = '1'

for c in s:
    if c == '1':
        one += 1
    else:
        two = c
        break

if k <= one:
    print(1)
else:
    print(two)

Solution (Python):
S = input()
K = int(input())

for i in range(0, len(S)):
    if S[i] == '1':
        if K == i+1:
            print(S[i])
            break
        elif S[i+1] != '1':
            print(S[i+1])
            break
    else:
        print(S[0])
        break

Solution (Python):
s = input()
k = int(input())

for i in range(k):
    if s[i] == '1':
        continue
    else:
        print(s[i])
        break
else:
    print(1)

Solution (Python):
s=list(input())
k=int(input())



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

Solution (Python):
s = list(map(int, list(str(input()))))
k = int(input())
i = 0
if s.count(1) == len(s):
  print(1)
else:
  while s[i] == 1:
    i += 1
  if k <= i:
    print(1)
  else:
    print(s[i])

Solution (Python):
S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    quit()

if K == 1:
    print(S[0])
    quit()

n = 0
while n < len(S):
    if S[n] != '1':
        break
    else:
        n += 1

if K <= n:
    print(1)
else:
    print(S[n])

Solution (Python):
S = list(str(input()))
K = int(input())

cc = 0
for i in S:
  if i != "1":
    break
  else:
    cc += 1
if cc < K:
  print(i)
else:
  print(1)

Solution (Python):
s=input()
k=int(input())
count=0
for number in s:
    if(number!='1'):
        break;
    count+=1
if(k<=count):
    print(1)
else:
    print(s[count])

Solution (Python):
S = [int(x) for x in list(str(input()))]
K = int(input())
j=1
i=-1

while( j==1 and i<len(S)-1 ):
  i = i+1
  j = S[i]

if(K<=i):  print(1)
else:  print(j)

Solution (Python):


S = input()
K = input()
K_len = len(K)
K = int(K)

Cn = []



for str in S:
    si = int(str)
    if si == 1:
        Cn.append(1)
    else:
        Cn.append(10000000000000000000)


tmp = 0
for i,Ci in enumerate(Cn):
    tmp += Ci
    if K <= tmp:
        print(S[i])
        break

Solution (Python):
S = list(input())
N, = list(map(int,input().split()))

ans = 1
num_1 = 0

for i in range(len(S)):
    if  not S[i] == '1':
        ans = int(S[i])
        break
    else:
        num_1 += 1

if  len(S) == 1:
    ans = int(S[0])
if  num_1 >= N:
    ans = 1
        
print(ans)

Solution (Python):
import sys
s=input()
k=int(input())
if k<105:
    if s[:k]=="1"*k:
        print("1")
        sys.exit(0)
i=0
while True:
    if s[i]!="1":
        print(s[i])
        break
    i+=1

Solution (Python):
s = input()
k = input()

index = 1

ans = 1

for i, c in enumerate(s, 1):
    if c != '1':
        ans = c
        break
    elif k == str(i):
        break


print(ans)

Solution (Python):
S=input()
K=int(input())
S1=""
if K==1:
	print(int(S[0:1]))
elif K>100:
	print(S.replace("1","")[0:1])
else:
	for i in range(K):
		S1=S1+"1"
	if S[0:K]==S1:
		print(1)
	else:
		print(S.replace("1","")[0:1])

Solution (Python):
from sys import stdin, stdout

input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    S = input()
    K = int(input())

    if K == 1:
        print(S[0])
    else:
        for s in S:
            if s == '1':
                K -= 1
            else:
                print(s)
                break
            if not K:
                print(s)
                break

main()

Solution (Python):
s = input()
k = int(input())

i=0
for c in s:
    if c!="1":
        res=c
        
        break
    i+=1

if k>i:
    print(res)
else:
    print(1)

Solution (Python):
s = list(input())
s = [int(i) for i in s]
k = int(input())

for i in s:
    num = i
    if i == 1:
        k -= 1
        if k == 0:
            break
    else:
        break

print(num)

Solution (Python):
s=input()
k=int(input())
c=0

if k==1:
  print(s[0])
elif k>1:
  while c<k-1 and s[c]=="1":
    c+=1

  if k-1<c:
    print(s[c-1])
  else:
    print(s[c])

Solution (Python):
from fractions import gcd
from sys import stdin
import math 
S = str(input())
K = int(input())
ans = 1

for itr in range(100):
    if S[itr] != '1':
        ans = int(S[itr])  
        break
    if itr+1 == K:
        break

print(ans)

Solution (Python):
s = input()
k = int(input())

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

Solution (Python):
s = input()
k = int(input())
a = 0
for i in range(0, k):
	if int(s[i]) != 1:
		print(s[i])
		a = 1
		break
if a == 0:
	print("1")

Solution (Python):
s = input()
k = input()
nlen = 0
i = 0
if s[i] != "1":
    print(s[i])
else:
    while s[i] == "1":
        if nlen == (int(k)-1):
            break
        i += 1
        nlen += 1
    print(s[i])

Solution (Python):
line = input()
flag = True

for i in range(int(input())):
  if not(line[i]== '1'):
    print(line[i])
    flag = False
    break

if flag:
  print('1')

Solution (Python):
import math
S = input()
K = int(input())

chou = 5*(10**15)

for c in S:
  
  mag = int(c)
  if mag == 1:
    if K == 1:
      print(1)
      quit()
    else:
      K -= 1
      continue
  if chou >= math.log(K,mag):
    print(c)
    quit()
  
  else:
    K -= mag**chou
    print(K)

Solution (Python):

N = list(input())
L = int(input())

count = 0

for n in N:
    if n == "1":
        count+=1
    else:
        break

if count >= L:
    print(1)
else:
    print(N[count])

Solution (Python):
A=list(input())
B=int(input())
count=0
for i in A:
    if int(i)==1:
        pass
        count+=1
        if count==B:
            print(1)
            exit()
    else:
        print(i)
        exit()

Solution (Python):

"""
Created on Sat Aug 18 20:38:47 2018
ABC106C
@author: maezawa
"""

s = input()
k = int(input())

if s[0]=='1':
    ans = 1
    cnt = 0
    for c in s:
        if c == '1':
            cnt += 1
        else:
            ans = c
            break
    if k <= cnt:
        print('1')
    else:
        print(ans)
else:
    print(s[0])

Solution (Python):
s = str(input())
k = int(input())
s = list(s)
count = 0
for i in s:
    if i != '1':
        break
    count += 1
if count >= k:
    print(1)
else:
    print(s[count])

Solution (Python):
s = input()
k = int(input())

flg = False

m = k
if len(s) < k:
    m = len(s)

for i in range(m):
    if s[i] != '1':
        print(s[i])
        flg = True
        break

if flg == False:
    print("1")

Solution (Python):
s = str(input())
n = int(input())


one = 0
ret = 0
for i in range(len(s)):
    if int(s[i]) == 1:
        one += 1
    else:
        ret = int(s[i])
        break

if one >= n:
    print(1)
else:
    print(ret)

Solution (Python):
data = input()
num = int(input())

cnt = 0
for lop in range(len(data)):
    if int(data[lop]) == 1:
        cnt = cnt + 1
        if num == cnt:
            print(data[lop])
            break
    else :    
        cnt = cnt + (int(data[lop])*1000000000000000000)**5
        if cnt > num:
            print(data[lop])
            break

Solution (Python):
s = input()
k = int(input())

count = 0
for i in s:
    if(int(i) == 1):
        count += 1
    else:
        break

if count >= k:
    print(1)
else:
    print(int(s[count]))

Solution (Python):

import sys

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())

    for c in s:
        if c=='1':
            k -= 1
            if k==0:
                print(c)
                break
            else:
                continue
        else:
            print(c)
            break


if __name__=='__main__':
    main()

Solution (Python):
def findFirstNot1(arg):
    ret = 1000
    ichi = 0
    for c in range(0, len(arg)):
        if arg[c] == '1':
            ichi += 1
        else:
            return ichi + 1
    return ret

instr = input()
nanmojime = int(input())
first1igai = findFirstNot1(instr)
if first1igai > nanmojime:
    ans = 1
else:
    ans = int(instr[first1igai - 1])
print(ans)

Solution (Python):
A = raw_input()
C = raw_input()

B = int(C)

num = map(int, str(A))

numnum = len(num)


i = 0

while num[i] == 1 and numnum-1 > i:
  i = i +1

  
if i < B:
  print num[i]
elif i > B-1:
  print 1

Solution (Python):





def main(s, k):
    
    
    for i in range(k):
        if '1' != s[i:i+1]:
            print(s[i:i+1])
            return
    print(1)
    
    
if __name__ == '__main__':
    try:
        s = input().strip()
        k = int(input().strip())
        main(s, k)
    except EOFError:
        pass

Solution (Python):
S = (input())						
K = int(input())						








iLen = len(S)
iMin = min(iLen, K)

ans="1"
for i in range(iMin):
	c = S[i]
	if (c=="1"): continue
	ans = c
	break

print(ans)

Solution (Python):

S=input()
K=int(input())
num='23456789'
if S[0]!='1':
    print(int(S[0]))
else:
    n=1
    while True:
        if n==len(S):
            n-=1
            break
        elif S[n]!='1':
            break
        n+=1
    if K-1<n:
        print(1)
    else:
        print(int(S[n]))

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

Solution (Python):

s = input()
k = int(input())

l = len(s)
ones = 0
i = 0
while s[i] == '1':
    ones += 1
    i += 1
    if i == l:
        break

if ones >= k:
    print('1')
else:
    print(s[i])

Solution (Python):
Ss = input()
K = int(input())

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

Solution (Python):
s = list(input())
k = int(input())

big = False

for i in range(len(s)):
    if s[i] != '1':
        big = i
        break

if not big:
    ans = s[0]
elif k <= big:
    ans = 1
else:
    ans = s[big]

print(ans)

Solution (Python):
s = input()
k = int(input())

first_pos = -1
for i in range(len(s)):
    if s[i] != '1':
        first = s[i]
        first_pos = i + 1
        break

if first_pos == -1 or first_pos > k:
    print(1)
else:
    print(first)

Solution (Python):
S = input()
K = int(input())

if S[0] != "1":
    print(S[0])
    
else:
    for n in range(K):
        if S[n] == "1":
            continue
        
        print(S[n])
        break
    else:
        print(S[K-1])

Solution (Python):


def main():
    s = input()
    k = int(input())

    for i, c in enumerate(s):
        if c == '1':
            if i == k - 1:
                print('1')
                break
            else:
                continue
        else:
            print(c)
            break


if __name__ == '__main__':
    main()

Solution (Python):

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

s = list(S)

count1 = 0
greater = 0

for c in s:
    if c=="1":
        count1+=1
    else:
        greater = c
        break

if K <= count1:
    print("1")
else:
    print(greater)

Solution (Python):
s=input()
k=int(input())

for i, si in enumerate(s):
    if i==k:
        print(1)
        exit()
    if si!='1':
        print(si)
        exit()
else:
    print(si)

Solution (Python):
def main():
    s = input()
    k = int(input())
    
    ss = ''
    for w in s:
        if w == '1':
            ss += w
        else:
            break
    if len(ss) >= k:
        print(1)
        return
    for w in s:
        if w != '1':
            print(w)
            break



if __name__ == '__main__':
    main()

Solution (Python):
a = input()
k = int(input())


n1 = 10**19
for i in range(2,10):
    if str(i) in a:
        temp = a.find(str(i))
        if temp < n1:
            n1 = temp
            num = i

if k <= n1:
    print(1)
else:
    print(num)

Solution (Python):
S = list(input())
K = int(input())

c = 0
cnt = 0
for i in S:
    if int(i) != 1:
        c = int(i)
        break
    cnt += 1


if K <= cnt:
    print(1)
else:
    print(c)

Solution (Python):
s=int(input())
k=int(input())

st=str(s)
l=len(st)
i=0
a=0
n=0
m=0

while n<1:
    if int(st[m])==1:
        m+=1
        a+=1
    else:
        n=1
    if a==l:
        n=1

if a>=k:
    print(1)

else:
    while i<=l:
        if int(st[i])!=1:
            print(int(st[i]))
            i=l+1
        else:
            i+=1

Solution (Python):
s =  int(input())
k =  int(input())

def main(string_s):
    for i, j in enumerate(str(string_s)):


        if j != '1':
            break
        if i+1 == k:
            print('1')
            return
    if str(s).lstrip('1') == '':
         print('1')
         return
    if str(s).lstrip('1')[0] == '2':
        print('2')
    elif str(s).lstrip('1')[0] == '3':
        print('3')
    elif str(s).lstrip('1')[0] == '4':
        print('4')
    elif str(s).lstrip('1')[0] == '5':
        print('5')
    elif str(s).lstrip('1')[0] == '6':
        print('6')
    elif str(s).lstrip('1')[0] == '7':
        print('7')
    elif str(s).lstrip('1')[0] == '8':
        print('8')
    elif str(s).lstrip('1')[0] == '9':
        print('9')
    else:
        print('1')

main(s)

Solution (Python):
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),100)
    if(i==0):
        m[i]+=var
    if(i>=1):
        m[i]+=(m[i-1]+var)
    if(k<=m[i]):
        print(l[i])
        exit()

Solution (Python):
S=list(input())
K=int(input())
idx=[-1]*10
for i in '123456789':
    if i in S:
        idx[int(i)] = S.index(i)+1
if idx[2:]==[-1]*8 or K < max(idx[2:]):
    print(1)
else:
    print(S[min(i for i in idx[2:]if i>0)-1])

Solution (Python):
s = input()
k = int(input())

import numpy as np

ind = np.inf

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

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

ans()

Solution (Python):
s = input()
k = int(input())
if len(s) == 1:
    print(s)
else:
    i = 0
    while i <= k-1:
        if s[i] != '1':
            print(s[i])
            exit()
        else:
            i += 1
    print(1)

Solution (Python):
s = list(input())
k = int(input())

if len(s) == 1:
    print(s[0])
else:
    for i in s:
        if int(i) == 1:
            k -= 1
            if k == 0:
                print(1)
                exit(0)
        else:
            print(i)
            exit(0)

Solution (Python):
s = input()
k = int(input())

for i,a in enumerate(s):
    if (a != '1' ) or k==i+1:
        ans = int(a)
        break

print (ans)

Solution (Python):
from sys import stdin

S = stdin.readline().rstrip()
K = int(stdin.readline().rstrip())

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

Solution (Python):
s = input()
k = int(input())

x = 0
ans1 = []
for x in range(len(s)):
    if s[x] == '1':
        ans1.append(x+1)
        x += 1
    else:
        break

if k in ans1:
    print('1')
else:
    print(s[x])

Solution (Python):
S = input()
K = int(input())
one_length = 0
next_num = '1'
for (i, s) in enumerate(S):
    if s != '1':
        one_length = i
        next_num = s
        break

if one_length < K:
    print(str(next_num))
else:
    print('1')

Solution (Python):
s = input()
k = int(input())

l=0

while s[l] == '1':
    l+=1
    if l >= len(s):
        l -= 1
        break

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)

Solution (Python):
S = input()
K = int(input())


for i, s in enumerate(S):
    if s == "1":
        if i + 1 == K:
            print(1)
            exit()
    else:
        print(s)
        exit()

Solution (Python):
import sys
s=input()
k=int(input())
if(len(s)==1):
    print(s[0])
    sys.exit()
if(k==1):
    print(s[0])
    sys.exit()
c=0
for i in range(k):
    if(s[i]=='1'):c+=1
    else:break
if(c==k):
    print(1)
else:
    print(s[c])

Solution (Python):
S = input()
K = int(input())

ans = '1'
one = 0
for i, s in enumerate(S):
    if s == '1':
        one += 1
        continue

    ans = s
    break

if K <= one:
    ans = '1'

print(ans)

Solution (Python):




def main():
    s, k = input(), int(input())

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

    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            idx = i
            break

    if k < idx + 1:
        print("1")
    else:
        print(s[idx])


if __name__ == '__main__':
    main()