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):

import math
import sys

import math
import sys


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


def solve(s, k):
  keta = 0
  for c in s:
    keta += int(c)**(5*10**5)
    if keta >= k:
      return(int(c))

if __name__ == "__main__":
  print(solve(S,K))

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

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 
lst.reverse()

if len(lst) == lst.count(1):
	print(1)

elif K == lst[:K].count(1):
	print(1)
  
else:
	for i in range(K):
		if lst[i] != 1:
			print(lst[i])
			break

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

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

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

Solution (Python):


II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    S = input()
    K = II()
    for c in S:
        if c == "1":
            K -= 1
            if K == 0:
                return c
        else:
            return c


if __name__ == "__main__":
    print(main())

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

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

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

if len(S) >= K and set(S[:K]) == {'1'}:
    print(1)
else:
    for i in S:
        if i != '1':
            print(int(i))
            exit()

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

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

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

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

p = 0
for i in s:
    if p == k-1:
        print(i)
        exit()
    if i != '1':
        print(i)
        exit()
    p += 1
print(i)

Solution (Python):
S=input()
k=int(input())
ans='1'

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

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

for i, s in enumerate(S):
  if int(s)==1:
    if i+1 < K:
      continue
    if i+1==K:
      print('1')
      break
  else:
    print(s)
    break

Solution (Python):
s = str(input())
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)

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

n = 0 
for s in S:
    if s=='1':
        n += 1
    else:
        break

if K-1<n:
    print('1')
else:
    print(s)

Solution (Python):
str_s = input()
int_k = int(input())

result = ""

for s in str_s[0:int_k]:
    if s != "1":
        result = s
        break
else:
    result = "1"

print(result)

Solution (Python):
S = input()
K = int(input())
for i, s in enumerate(S):
    if s != "1":
        print(s)
        break
    if i + 1 >= K:
        print(s)
        break

Solution (Python):
s=input()
k=int(input())
n=len(s)
z=5*10**15
if int(s[0])!=1:
  print(int(s[0]))
else:
  x=0
  for i in range(n):
    if s[i]=='1':
      x+=1
    else:
      break
  if k>x:
    print(int(s[x]))
  else:
    print(1)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  K = int(input())
  
  ans = 1
  for i in range(min(K, len(S))):
    c = int(S[i])
    if c != 1:
      ans = c
      break
  print(ans)


if __name__ == '__main__':
  main()

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

cnt=0
flag=0
if int(s[0]) > 1:
  ans=s[0]
else:
  for i in range(len(s)):
    if int(s[i])==1 and flag==0:
      cnt+=1
    else:
      flag=1

if k <= cnt:
  ans=1
else:
  ans=s[cnt]

print(ans)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(S, K):
    if min(S) == max(S) == '1':
        return 1
    else:
        for i in range(len(S)):
            if S[i] != '1':
                if K <= i:
                    return 1
                else:
                    return int(S[i])

S = input()
K = int(input())
print(solve(S, K))

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

first = ''
pos = l
for i in range(l):
	if s[i] != '1':
		first = s[i]
		pos = i
		break

print('1' if k <= pos else first)

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

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

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

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

Solution (Python):

a=input()
k=int(input())
if int(a)<10:
    a=str(int(a)*11)
i=0
x=0

while k>=0:
    if a[i]=='1':
        k-=1
        i+=1
        if k==0:
            x=1
            k=-1
    else: 
        k=-1


print(a[i-x])

Solution (Python):
a=input()
k=int(input())
if int(a)<10:
    a=str(int(a)*11)
i=0
x=0
while k>=0:
    if a[i]=='1':
        k-=1
        i+=1
        if k==0:
            x=1
            k=-1
    else: 
        k=-1
print(a[i-x])

Solution (Python):


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

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

Solution (Python):
class Solver(object):
    def __init__(self):
        self.s = input()
        self.k = int(input())
        self.compressed = self.to_compressed_format(self.s)

    def solve(self):
        if (self.compressed[0][0] == 1) and (self.k <= self.compressed[0][1]):
            print(1)
            return
        else:
            for i in self.s:
                if int(i) != 1:
                    print(i)
                    return
            print(1)
            return

    def wrong_solve(self):
        print(self.compressed)
        counter = 0
        for (n, count) in self.compressed:
            print(n, count)
            counter += self.length_after(n, count)
            print("chk")
            if counter >= self.k:
                return n

    @staticmethod
    def length_after(n, count):
        return count * (n ** (5 * (10 ** 15)))

    @staticmethod
    def to_compressed_format(s):
        res = []
        counter = 1
        prev = int(s[0])
        for c in s[1:]:
            n = int(c)
            if n == prev:
                counter += 1
            else:
                res.append((prev, counter))
                prev = int(n)
                counter = 1
        res.append((prev, counter))
        return res


if __name__ == "__main__":
    s = Solver()
    s.solve()

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

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

Solution (Python):
s = input()
K = int(input())
len1 = len(s)-len(s.lstrip("1"))
if len1 >= K:
    print(1)
else:
    print(s.lstrip("1")[0])

Solution (Python):
def solve(S, K):
    for s in S[:K]:
        if s != "1":
            return s
    return "1"

if __name__ == "__main__":
    S = input()
    K = int(input())
    print(solve(S, K))

Solution (Python):
N=input()
for count in range(len(N)):  
    if N[count]!="1":    break
if int(input())>count:    print(N[count])
else:    print(1)

Solution (Python):

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

n = len(S)

for i in range(n):
    if not S[i] == "1":
        break
if K <= i:
    print(1)
else:
    print(S[i])

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

if len(s) == 1:
    print(s)
else:
    if s[0] != '1':
        print(s[0])
    else:
        cnt = 0
        for i in range(len(s)):
            if s[i] == '1':
                cnt += 1
            else:
                not1 = s[i]
                break
                
        if k <= cnt:
            print(1)
        else:
            print(not1)

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


s_arr = [int(i) for i in s]

one = 0
num = 0
for i in range(len(s_arr)):
    if s_arr[i] == 1:
        one += 1
    else:
        num = s_arr[i]
        break

if k <= one:
    print(1)

else:
    print(num)

Solution (Python):
def main(sbj:str,n:int):
    ans =sbj[0]
    if ans!="1":
        return int(ans)
    counter=0
    for i in range(len(sbj)):
        if sbj[i]=="1":
            counter += 1
            if counter >=n:
                return 1
        else:
            return int(sbj[i])
sbj = input()
n =int(input())
print(main(sbj,n))

Solution (Python):


















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


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

f = False
for s in S[:K]:
  if s != "1":
    print(s)
    f = True
    break

if not f:
  print(1)

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

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

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

for s in S:
  if(s == "1"):
    K -= 1
    if(K == 0):
      ans = 1
      break
  else:
    ans = s
    break
print(ans)

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

for i in range(len(S)):
  if(S[i] == "1"):
    K -= 1
    if(K == 0):
      print(1)
      break
  else:
    print(S[i])
    break

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

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

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

ans = '1'
for a in s[:k]:
    if a != '1':
        ans = a
        break

print(ans)

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

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

for i, s in enumerate(S):
    if s != '1':
        t = i
        break
    if i == len(S)-1:
        t = 0
print (1 if K <= t else S[t] )

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

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

Solution (Python):

import sys

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

count = 0
slist = list(S)
while(len(slist) > 0):
    a = slist.pop(0)
    count += 1
    if a != '1':
        print(a)
        sys.exit(0)
    if count == K:
        print(1)
        sys.exit(0)
print(1)

Solution (Python):
s=list(input())
k=int(input())
c=0
ind=-1
indx=-1
f=True
for i in range(len(s)):
  if s[i]=='1':
    c+=1
  else:
    ind=i
    indx=s[i]
    f=False
    break
if f or k<ind+1:
  print(1)
else:
  print(indx)

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

D=5000000000000000

tmp=0
for s in S:
  if s=='1':
    tmp+=1
    if tmp>=K:
      print(s)
      break
    continue
    
  t=1
  for _ in range(D):
    t=t*int(s)
    if tmp+t>=K:
      print(s)
      break
  else:
    tmp+=t
    continue
  break

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

for i in range(k):
    if int(s[i]) > 1:
        print(s[i])
        exit()
print(1)

Solution (Python):
def main():
    S = list(map(int, input()))
    K = int(input())

    for i in S:
        if i == 1:
            K -= 1
            if K == 0:
                print(1)
                exit()
            continue
        j = 1
        while i < 5 * 10 ** 15:
            if i ** j >= K:
                print(i)
                exit()
            j += 1
        K -= i ** j


main()

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

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

Solution (Python):

def db(x): 
    global debug
    if debug: print(x)
debug = False
S = input()
K = int(input())
for i in range(len(S)):
    if S[i]!='1': break
if i>=K: print('1')
else:   print(S[i])

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

if len(s) >=k:
    flag = True
    for i in range(k):
        if s[i] != "1":
            flag = False
            break
    if flag:
        print(1)
        exit()
for i in s:
    if i != "1":
        print(i)
        exit()

Solution (Python):


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

    m = -1
    c = ''
    for i in range(len(S)):
        if S[i] == '1':
            m = i
        else:
            c = S[i]
            break

    m += 1


    print('1' if K <= m else c)


if __name__ == '__main__':
    main()

Solution (Python):



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

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

Solution (Python):
S = input()
K = int(input())
if K == 1:
  print(S[0])
else:
  for i in range(len(S)):
    if int(S[i]) != 1 or K - i == 1:
      print(S[i])
      break

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

ans = '1'
for i in range(len(S)):
    if i + 1 <= k and S[i] != '1':
        ans = S[i]
        break
        
print(ans)

Solution (Python):
S = input()
K = int(input())
ans = []

for i in S:
    if i == '1':
        ans.append(i)
    else:
        ans.append(i)
        break

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

Solution (Python):
S =input()
K =int(input())
n = len(S)
for i,j in enumerate(S):
    if j!="1":
        n = i+1
        break
if K < n:
    print(1)
else:
    print(S[n-1])

Solution (Python):


def main():
    s = list(input())
    k = int(input())
    n = len(s)
    for i in reversed(range(n)):
        if s[i] != "1":
            s[i:n] = s[i] * (n - i)
    if k <= n:
        print(s[k - 1])
    else:
        print(s[-1])

main()

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

flag = 0

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

Solution (Python):
S = input()
K = int(input())
cnt = 0
for x in S:
    if x == '1':
        cnt += 1
    else:
      break

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

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

renzoku=0
for i in S:
    if i=='1':
        renzoku+=1
    else:
        break
if K<=renzoku:
    ans = '1'
else:
    ans = S[renzoku]
print(ans)

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

if all(c == '1' for c in s[0:k]):
    print('1')
else:
    print(next(c for c in s if c != '1'))

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

sum=0
for i in range(0,len(S)):
    if(S[i]==1):
        sum+=1
        if(sum>=K):
                print(S[i])
                exit()
    else:
        tmp=S[i]
        for j in range(2,5000000000000000):
            tmp*=S[i]
            if(sum+tmp>=K):
                print(S[i])
                exit()
            else:
                sum+=tmp

Solution (Python):
a = list(input())
b = int(input())
total = 0
for i in a:
    i = int(i)
    if(i == 1):
        total += 1
    else:
        print(i)
        break
    if(total >= b):
        print(i)
        break

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

for i, c in enumerate(S):
    n = int(c)
    if i==K-1:
        ans = int(c)
        break
    if n!=1:
        ans = int(c)
        break

print(ans)

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

Solution (Python):
S = input()
K = int(input())
Sdash = [x for x in S if not x == '1'] 

if len(Sdash) == 0:
    n = len(S) 
else:
    n = S.index(Sdash[0])

if n >= K:
    print(1)
else:
    print(Sdash[0])

Solution (Python):
s = input()
k = int(input())
count = 1
ans = ''

for a in s:
    if a != '1':
        ans = a
        break
    else:
        count += 1

if count <= k:
    print(ans)
else:
    print(1)

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

for i, s in enumerate(S):
	if s is not '1' and i + 1 <= K:
		print(s)
		break
else:
	print('1')

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

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

Solution (Python):
s=input()
k=int(input())
a=0
b=min(len(s), k)
for i in range(b-1):
  if(int(s[a])==1):
    a+=1
  else:
    break
print(int(s[a]))

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

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

Solution (Python):
S = input()
K = int(input())
a = 0
if S[0] != '1':
  print(S[0])
else:
  for i in S:
    if i == '1':
      a += 1
    else:
      temp = i
      break
  if a >= K:
      print('1')
  else:
      print(temp)

Solution (Python):



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

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

    if s[0] != '1':
        print(s[0])
    else:
        if k <= count:
            print(1)
        else:
            print(s[count])


if __name__ == '__main__':
    main()

Solution (Python):
def solve(s, k):
    for i in range(k):
        if s[i] != "1":
            return s[i]
    return "1"


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

print(solve(S, K))

Solution (Python):
S = input()
k = int(input())
ans = 1

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

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

for i, s in enumerate(S):
    if s == "1" and i + 1 < k:
        continue
    print(s)
    break
else:
    print(S[-1])

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

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

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

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

default = '1'
last_one_index = 0
for i, c in enumerate(s):
    if c != '1':
        default = c
        last_one_index = i
        break
if k <= last_one_index:
    print('1')
else:
    print(default)

Solution (Python):
S = int(input())
K = int(input())
import numpy as np

S_list = list(map(int, str(S)))


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


if len(S_list) == 1:
    print(int(S_list[0]))
    exit()


if count < K:
    S_list = np.array(S_list).reshape(-1,1)
    print(int(S_list[count]))
else:
    print(1)

Solution (Python):
s = list(input())
k = int(input())
nonone = 0
for c in s:
    if c == '1':
        nonone += 1
    else: break
if k - 1 >= nonone:
    print(s[nonone])
else:
    print(1)

Solution (Python):
s = input()
k = int(input())
for i,j in enumerate(s):
  if j == "1":
    if (i+1) == k:
      print("1")
      break
  else:
    print(j)
    break

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

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = list(input())
k = int(input())
for i in range(k):
    if n[i] != '1':
        print(n[i])
        sys.exit()
print(1)

Solution (Python):
import copy
N=input()
s=int(input())
b=N[0]
c=0
x=[]
for a in N:
	if a != b:
		x.append([int(b),c])
		b=a
		c=0
	c+=1
x.append([int(b),c])
y=[]
while x != y:
	y=copy.deepcopy(x)
	p=0
	for i in range(len(x)):
		p += x[i][1]
		if p > s:
			break
		x[i][1]=x[i][1]*x[i][0]
w=0
for xx in x:
	w += xx[1]
	if w >= s:
		print(xx[0])
		break

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

for i in S:
    if K == 1:
        print(i)
        break
    elif i == "1":
        K -= 1
    else:
        print(i)
        break

Solution (Python):
def main():
    s = input()
    k = int(input())
    for i in range(0, k - 1):
        if s[i] != '1':
            print(s[i])
            return
    print(s[k - 1])


if __name__ == '__main__':
    main()

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

ans = 0
n1 = 0

for i in S:
    if i != "1":
        s = int(i)
        break
    
    else:
        n1 += 1

if n1 >= K:
    print(1)

else:
    print(s)

Solution (Python):
a = input()
b = int(input())
n1 = 0
s = 0
for i in a:
    if i!="1":
        s = int(i)
        break
    n1 +=1
if n1 >= b:
    print(1)
else:
    print(s)

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

count = 0
not_one = 0

for i in S:
    num = int(i)
    if num != 1:
        not_one = num
        break
    else:
        count += 1

if K <= count:
    print(1)
else:
    print(not_one)

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

ans = 1
for i in range(min(K, len(S))):
    if(S[i] != "1"):
        ans = S[i]
        break
        
print(ans)

Solution (Python):
from sys import stdin
from math import log10

gosen = 5e15

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

logK = log10(K)
Sstr = str(S)

Kres = K
for i in range(0, len(Sstr)):
    Si = int(Sstr[i])
    if Si == 1:
        Kres = Kres - 1
    else:
        print(Si)
        break
    if Kres <= 0:
        print(Si)
        break

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

d = re.search('[2-9]', S)
if d == None or d.start() >= K:
  print("1")
else:
  print(d.group())

Solution (Python):
import re

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

def main():
    global K
    m = re.search(r'[2-9]', S)
    if m:
        i = m.start()
        index = min([m.start(), K - 1])
        ans = list(S).pop(index)
    else:
        ans = 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
S = list(input())
k = int(input())
ans = 0
count = 0

for s in S:
    if s != '1':
        ans = s
        break
    else:
        count += 1
        
if count >= k:
    print('1')
else:
    print(ans)

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


if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while i < len(S) and S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

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

for i in range(k):
  if s[i]!="1":
    break
print(s[i])

Solution (Python):
S = list(input())
k = int(input())
count = 0
ans = 0

for i in S:
    if i != '1':
        ans = i
        break
    else:
        count += 1

if count >= k:
    print('1')
else:
    print(ans)

Solution (Python):
a = input()
b = int(input())
br = []
count = 0
if b == 1:
    print(a[0])
else:
    if len(a) >= b:
        for i in range(b):
            if a[i] == "1":
                count += 1
        if count == b:
            print(1)
        else:
            for r in (list(a)):
                if r != "1":
                    print(r)
                    exit()
    else:
            for r in (list(a)):
                if r != "1":
                    print(r)
                    exit()

Solution (Python):
S = input()
K = int(input())
counter = 0
num = 1
log = 0
for i in S:
    if int(i) != 1:
        log = counter
        num = int(i)
        break
    counter += 1

if K <= log:
    print(1)
else:
    print(num)

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


x = "1"
for i in S:
	if i == "1":
		pass
	else:
		x = i
		break

if x != "1":
	if S.index(x) + 1 <= K:
		print(x)
	else:
		print(1)
else:
	print(1)

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

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

Solution (Python):
def main():
    s = input()
    k = int(input())
    count = 0
    last_num = 0
    for i in s:
        if i == '1':
            count += 1 
        else:
            last_num = i
            break
    if k > count:
        print(last_num)
    else:
        print(1)
if __name__ == "__main__":
    main()

Solution (Python):
import sys



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

for i in range(len(S)):
    if(S[i] == "1" and i+1 == K):
        print("1")
        sys.exit()
    elif(S[i]!="1"):
        print(S[i])
        sys.exit()

Solution (Python):
import sys




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

for i in range(len(S)):
    if (S[i] == "1"):
        numplace+=1
    else:
        numplace+= 5000000000000000**int(S[i])
    if(numplace>=K):
        print(S[i])
        sys.exit()

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

expi = len(s)
expn = 1
for i in range(1, len(s) + 1):
    if s[i-1] == "1":
        continue
    expi = i
    expn = s[i-1]
    break

if expi <= K:
    print(expn)
else:
    print(s[K-1])

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

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

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






a = 1
ocount = 0
for i in range(len(s)):
    t = int(s[i])
    if t != 1:
        a = t
        break
    else:
        ocount += 1

if k <= ocount:
    print(1)
else:
    print(a)

Solution (Python):
s = list(input())
k = int(input())
one_count = 0
stop_flag = 0

for i in s:
    if i != '1':
        if one_count >= k:
            print(1)
        else:
            print(i)
        stop_flag = 1
        break
    else:
        one_count += 1
        
if stop_flag == 0:
    if one_count >= k:
        print(1)
    else:
        print(0)

Solution (Python):
S = input()
K = int(input())
one_count = 0
ans = 0

for i in range(len(S)):
    if S[i] != '1':
        ans = S[i]
        break
    else:
        one_count += 1

if one_count >= K:
    print('1')
else:
    print(ans)

Solution (Python):
S = int(input())
K = int(input())
f = 0
ans = 10

list = [i for i in str(S)]
 
for i in range(K):
    if int(list[i]) > 1:
        ans = min(ans,int(list[i]))
        f = 1
        break

if f == 0:
    print(1)
else:
    print(ans)

Solution (Python):
S = input().rstrip()
K = int(input())
c = 0
for item in S:
  if not item == "1":
    break
  c+=1
n = S[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)

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

	is_1 = True
	for i in range(K) :
		if (len(S) < i) :
			break

		
		if (S[i] != "1") :
			is_1 = False
			break

	if (is_1) :
		print("1")
		return

	for i in range(len(S)) :
		if (S[i] == "1") :
			continue

		print(S[i])
		break


main()

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

	is_1 = True
	for i in range(K) :
		if (len(S) < i) :
			break

		
		if (S[i] != "1") :
			is_1 = False
			break

	if (is_1) :
		print("1")
		return

	for i in range(len(S)) :
		if (S[i] == "1") :
			continue

		print(S[i])
		break


main()

Solution (Python):
s = input()
k = int(input())
ans  = True
for i in range(k):
    if s[i] != '1':
        print(s[i])
        ans = False
        break
if ans:
    print(1)

Solution (Python):

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

if len(s)==1:
    print(s[0])
elif k==1:
    print(s[0])
else:
    cnt = 0
    idx = 0
    for c in list(s):
        idx += 1
        if c=="1":
            cnt += 1
        else:
            break
    if k<=cnt:
        print(1)
    else:
        print(s[idx-1])

Solution (Python):
S = input()
K = int(input())
cc = 0
st = 0
for i in S:
    if i == "1":
        cc += 1
    else:
        st = i
        break
if cc >= K:
    print(1)
else:
    print(st)

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

i = None
for i, s in enumerate(S):
    if s != "1":
        break

if i is None:
    print(S[0])
    exit()

if i >= K:
    print(1)
else:
    print(S[i])

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

for i in range(K):
    if S[i] != '1':
        print(S[i])
        flag = False
        break

if flag:
    print(1)

Solution (Python):
S=input()
K=int(input())
f=0
if(K<=len(S)):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
        f=1
if f==0:      
    for s in S:
        if(s!="1"):
            print(s)
            break

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

S = [int(e) for e in S]
days = 5 * 10**15
for e in S:
    result = 1
    if e == 1:
        K -= 1
        if K <= 0:
            print(e)
            exit()
        continue
    for f in range(days):
        result *= e
        if K - result <= 0:
            print(e)
            exit()
        if f == days - 1:
            K -= result

Solution (Python):

n=input()
count=0
l=int(input())
for i in range(len(n)):
  if(n[i]=='1'):
    count+=1
    if(l==count):
      print(n[i])
      break;
    continue
  else:
    print(n[i])
    break;

Solution (Python):
import sys

s = [int(i) for i in input()]
k = int(input())

for i, j in enumerate(s):
    if j != 1:
        break
    elif i == k-1:
        print(1)
        sys.exit()

for i in s:
    if i != 1:
        print(i)
        sys.exit()

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

for i in range(K):
    n=int(S[i])
    if n==1:
        if K-1==i:
            print(1)
            exit(0)
    else:
        print(n)
        exit(0)

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

for i in range(K) :
    if L[i] != "1" :
        print(L[i])
        break
    else :
        if i == K-1 :
            print(1)

Solution (Python):
import itertools
s = input()
k = int(input())
g = itertools.groupby(s)
v = -1
t = -1
for a,b in g:
    if v == -1:
        v = len(list(b))
    elif t == -1:
        t = a
        break
if s[0]=='1':
    if k<=v:
        print(1)
    else:
        print(t)
else:
    print(s[0])

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


if k <= len(s):
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            exit()
    print("1")
else:
    for w in s:
        if w != "1":
            print(w)
            exit()