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



Sample input:
1214
4


Sample output:
2

Submission status: Accepted

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

Submission status: Accepted

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



for si in s[:k]:
    sii  = int(si)
    if sii != 1:
        print(sii)
        exit()
else:
    print(1)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

S = LI2()
K = I()

for i in range(K):
    if S[i] != 1:
        print(S[i])
        exit()
    elif i == K-1 and S[i] == 1:
        print(1)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
if all(S[i]=="1" for i in range(min(K,len(S)))):
    print(1)
else:
    for i in range(min(K,len(S))):
        if S[i]!="1":
            print(int(S[i]))
            break

Submission status: Accepted

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

Submission status: Accepted

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

cnt_one = 0
for i in S:
    if i == '1':
        cnt_one += 1
    else:
        break

if cnt_one >= K:
    print(1)
else:
    print(S[cnt_one+1-1])

Submission status: Accepted

Solution code:
# coding = SJIS

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

ans = 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
k = I()
where = 0
while where < len(s):
    if s[where] == '1':
        where += 1
    else:
        break
print('1' if k <= where else s[where])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
K = int(input())
a = "1"
ind = len(S)
for i in range(len(S)):
    if S[i]!="1":
        a = S[i]
        ind = i
        break
if K<=ind:
    print(1)
else:
    print(a)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
t = -1
for k in range(len(S)):
    t = k
    if S[k] != "1":
        break
if K <= t:
    print(1)
else:
    print(S[t])

Submission status: Accepted

Solution code:
s = str(input())
k = int(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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s=input()
k=int(input())
for i in range(min(len(s),k)):
  if s[i]!='1':
    print(s[i])
    sys.exit()
print(1)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]
else:
    if ref >= K:
        ans = "1"
    else:
        ans = S[ref]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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):   # 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)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

c = s.count('1',0,k)

x = s.replace('1', '')

if len(x)==0:
    print(1)
else:
    if c ==k:
        print(1)
    else:
        print(x[0])

Submission status: Accepted

Solution code:
import sys
s=input()
k=int(input())
for i in range(min(len(s),k)):
  if s[i]!="1":
    print(s[i])
    sys.exit()
print(1)

Submission status: Accepted

Solution code:
s = list(input())
K = int(input())

i = 0
while(s[i]=='1'):
    K -= 1 
    if K == 0:
        break 
    i += 1 
print(s[i])

Submission status: Accepted

Solution code:
s=input()
n=len(s)
k=int(input())

index=-1
for i in range(n):
    if s[i]!='1':
        index=i
        break

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

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
for i in range(min(len(s), k)):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)

Submission status: Accepted

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

f = 1
d = 0

for c in s:
    if int(c) != 1:
        f = int(c)
        break
    else:
        d += 1

if d >= k:
    print(1)
else:
    print(f)

Submission status: Accepted

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

cnt = 0
for i in range(len(s)):
    if s[i]=="1":
        cnt += 1
    else:
        break

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

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
num=1
for i in range(len(s)):
  if s[i]!=str(1):
    num=i+1
    break


    
if k>=num:
  print(s[num-1])
else:
  print(1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if ind == -1:
  print(S[0])
elif ind + 1 >= K:
  print(1)
else:
  print(S[ind+1])

Submission status: Accepted

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

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

if s[0] == "1":
    if k <= one_counter:
        res = s[0]
    else:
        res = s[one_counter]
else:
    res = s[0]

print(res)

Submission status: Accepted

Solution code:
S=list(input())
K=int(input())
#print(S)
i=0;p=0;q=0
while i!=len(S):
  if S[i]!="1":
    p=1
    q=i
    if K<i+1:
      print("1")
    else:
      print(S[i])
    break
  i=i+1
if p==0:
  print("1")

Submission status: Accepted

Solution code:
s=input()
k=int(input())
l=0
for i in s:
    if i=="1":
        l+=1
    else:
        break
print("1" if k<=l else s[l])

Submission status: Accepted

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

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

print(ans) if ans else print(1)

Submission status: Accepted

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

cntone=0
while len(s)>cntone and s[cntone]=='1':
    cntone+=1

if k>cntone:
    print(s[cntone])
else:
    print(s[0])

Submission status: Accepted

Solution code:
S=input()
K=int(input())
for n in range(min(len(S),K)):
    if S[n]!="1":
        print(S[n])
        break
else:
    print(1)

Submission status: Accepted

Solution code:
from collections import deque
S=deque(list(map(int,list(input()))))
K=int(input())
i=0
while S:
    if S[0]==1:
        S.popleft()
        i+=1
    else:
        break
result=1 if K<=i else S[0]
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

if len(S) >= K and S[:K] == "1"*K:
    print(1)
else:
    for S in list(S):
        if S != "1":
            print(S)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    K = int(readline())
    K -= 1

    idx = 0
    for i, c in enumerate(S):
        if c != '1':
            idx = i
            break
    if idx > K:
        print(1)
    else:
        print(S[idx])

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, (list(ns()))))
    K = ni()
    for i in range(K):
        if S[i] != 1:
            print(S[i])
            return
    print(1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    k = int(input())
    for s in S[:k]:
        if s != '1':
            print(s)
            break
    else:
        print(1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().rstrip()
n = int(input().rstrip())

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
for i in range(len(S)):
  if i==K-1:
    print(S[i])
    exit()
  if S[i]!="1":
    print(S[i])
    exit()
print(1)

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    K = int(input())
    for i in range(K):
        if S[i] != "1":
            print(S[i])
            exit()
    print("1")
resolve()

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    k = int(input())
    c = 0
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            break
        if i == k-1:
            print(1)
resolve()

Submission status: Accepted

Solution code:
S = input()
k = int(input())
for i, s in enumerate(S, start=1):
    if s != "1":
        print(s)
        break
    if i == k:
        print(1)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=(input())
s=list(S)
K=int(input())
if K==1:
  print(s[0])
  exit()
for i in range(K):
  key=s[i]
  if key!='1':
    print(key)
    exit()
print(1)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(len(s)):
    num = int(s[i])
    if num == 1:
        cnt += 1
        if cnt == k:
            print(num)
            break          
    else:
        print(num)
        break

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for i, s in enumerate(S):
    if s == "1":
        K -= 1
    else:
        print(s)
        break
    if K <= 0:
        print("1")
        break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
if s[0] != "1":
    print(s[0])
elif s[:k].replace("1","")=="":
    print("1")
else:
    print(s.replace("1","")[0])

Submission status: Accepted

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

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

    if s != "1":
        print(s)
        exit()

Submission status: Accepted

Solution code:
s=input()
k=int(input())
c=0
for i in range(len(s)):
    if s[i]=="1":
        c+=1
    else:
        break
if k<=c:
    print("1")
else:
    print(s[c])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in s:
    if int(i)!=1:
        print(i)
        exit()
    k-=1
    if k<1:
        print(1)
        exit()

Submission status: Accepted

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

ans = -1
for s in S[:K]:
  x = int(s)
  if x != 1:
    ans = x
    break
else:
  ans = 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
cnt = 0
for l in s:
  if l!='1':
    break
  cnt += 1
if cnt>=k:
  print(1)
else:
  print(s[cnt])

Submission status: Accepted

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

ans=1
for i in range(min(len(s),k)):
    if int(s[i])!=1:
        ans=s[i]
        break

print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 106
# C - To Infinity

# 5000000000000000

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

whileone=-1
ans=-1
for i in range (len(S)):
    if S[i]=="1":
        whileone=i+1
    else:
        ans=S[i]
        break

if whileone>0 and whileone>=K:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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


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

print(s[i])

# if s[0] == "1":
#     if k == 1:
#         print(1)
#     else:
#         print(s[1])
# else:
#     print(s[0])

Submission status: Accepted

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

Submission status: Accepted

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

for s in S:
    if K != 1 and s == '1':
        K -= 1
        continue
    else:
        print(s)
        break

Submission status: Accepted

Solution code:
def solve():
  S = input()
  K = int(input())
  for k in range(K):
    if S[k]!='1':
      return S[k]
  return 1
print(solve())

Submission status: Accepted

Solution code:
#coding: utf-8

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

# find not one
pos = None

for i in range(len(S)):
    if S[i] != "1":
        pos = i
        break

#print("pos=%d" % pos)

if pos == None:
    print("1")
else:
    if K <= pos:
        print("1")
    else:
        print(S[i])

Submission status: Accepted

Solution code:
import re

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

Submission status: Accepted

Solution code:
import re

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

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

Submission status: Accepted

Solution code:
import re

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

m = re.match(r'\A(1+)([1-9]*)\Z', S)
if m:
    print('1' if len(m.group(1)) >= K else m.group(2)[0])
else:
    print(S[0])

Submission status: Accepted

Solution code:
s = input()
k = int(input())
cnt = 0
for i in range(len(s)):
    if s[i] != "1":
        x = s[i]
        break
    else:
        cnt += 1
if cnt >= k:
    print(1)
else:
    print(x)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

S = LI2()
K = I()

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

Submission status: Accepted

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

ans = 1
for i in S:
	if i != '1':
		ans = i
		break
	if K==1:
		ans = i
		break
	K-=1
print(ans)

Submission status: Accepted

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

count = 0
xString = ''
for i in range(len(S)):
    if S[i] == '1':
        count += 1
    else:
        xString = S[i]
        break

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

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
k=int(input())
c=0
for a in s:
    if a!="1":
        ans=a
        break
    else:
        c+=1
if k<=c:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

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

print(1)

Submission status: Accepted

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

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

print(1)

Submission status: Accepted

Solution code:
# abc106_c.py
# https://atcoder.jp/contests/abc106/tasks/abc106_c

# C - To Infinity /
# 実行時間制限: 2 sec / メモリ制限: 1000 MB
# 配点: 300点

# 問題文
# Mr. Infinity は, 1 から 9 までの数字からなる文字列 Sを持っている. この文字列は, 日付が変わるたびに次のように変化する.
#     文字列 S    に含まれるそれぞれの 2 が 22, 3 が 333, 4 が 4444, 5 が 55555, 6 が 666666, 7 が 7777777, 8 が 88888888, 9 が 999999999 に置き換わる. 1 は 1 のまま残る.
#     例えば, Sが 1324 の場合, 翌日には 1333224444 になり, 翌々日には 133333333322224444444444444444 になる.

# あなたは 5000 兆日後に文字列がどのようになっているか知りたい. 5000 兆日後の文字列の左から K文字目は何か？

# 制約
#     Sは 1 文字以上 100文字以下の文字列.
#     Kは 1 以上 1018以下の整数.
#     5000兆日後の文字列の長さは K文字以上である.

# 入力
# 入力は以下の形式で標準入力から与えられる.
# S
# K

# 出力
# 5000兆日後に Mr. Infinity が持っている文字列の K文字目の数字を出力しなさい.

# 入力例 1
# 1214
# 4

# 出力例 1
# 2

# 文字列 Sは次のように変化していく.

#     現在: 1214
#     1日後: 12214444
#     2日後: 1222214444444444444444
#     3日後: 12222222214444444444444444444444444444444444444444444444444444444444444444

# 5000兆日後の文字列の最初 5 文字は 12222 となる. K=4 なので, 4文字目の 2 を出力すればよい.

# 入力例 2
# 3
# 157

# 出力例 2
# 3

# 文字列ははじめ 3 である. 5000兆日経ったとき, 文字列は 3 だけで構成される.

# 入力例 3
# 299792458
# 9460730472580800

# 出力例 3
# 2


def calculation(lines):
    # A, B = list(map(int, lines[0].split()))
    S = lines[0]
    K = int(lines[1])
    n_seq1 = get_n_seq1(S)
    if n_seq1 >= K:
        return [1]
    else:
        return [S.replace('1', '')[0]]
    return [cnt]


def get_n_seq1(S):
    ret = 0
    for i in range(len(S)):
        if S[i] == '1':
            ret += 1
        else:
            return ret
    return ret


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1214', '4']
        lines_export = ['2']
    if pattern == 2:
        lines_input = ['3', '157']
        lines_export = ['3']
    if pattern == 3:
        lines_input = ['299792458', '9460730472580800']
        lines_export = ['2']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(S[k])

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	S = input()
	n = int(input())

	flg = False
	for x in range(n):
		if S[x] != "1":
			print(S[x])
			flg = True
			break
	if flg == False:
		print("1")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
A = str(input())
B = int(input())
count = 0

for i in range(len(A)):
    if A[i] == "1":
        count += 1
    else:
        if B <= count:
            print(1)
            sys.exit()
        else:
            print(A[i])
            sys.exit()
print(1)

Submission status: Accepted

Solution code:
import sys
A = str(input())
B = int(input())
count = 0

for i in range(len(A)):
    if A[i] == "1":
        count += 1
    else:
        if B <= count:
            print(1)
            sys.exit()
        else:
            print(A[i])
            sys.exit()
print(1)

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
ch=0
for i in range(len(s)):
  if s[i]=='1':
    ch+=1
  else:
    ss=s[i]
    break
    
if ch>=k:
  print(1)
else:
  print(str(ss))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
n = min(len(s), k)

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

print(1)

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for i, s in enu(S):
    if s != '1':
        print(s)
        exit()
    if i == K-1:
        print(s)
        exit()

Submission status: Accepted

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

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

print(S[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i, a in enumerate(s):
    if a != "1":
        ans = 1 if k<=i else int(a)
        break
else:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
count = 0
for i in range(len(s)) :
    if s[i] == "1" :
        count += 1
    else :
        break
if k > count :
    print(s[count])
else :
    print("1")

Submission status: Accepted

Solution code:
S = input()
K = int(input())
judge = 1

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

if judge != 0:
    print("1")

Submission status: Accepted

Solution code:
S =input()
K = int(input())
if S.count("1") == len(S):
  print(1)
else:
  for i in range(len(S)):
    if S[i] != "1":
      print(S[i])
      break
    elif i+1 == K:
      print(S[i])
      break

Submission status: Accepted

Solution code:
S = list(input())
S = [int(s) for s in S]

K = int(input())

num_digit = 0

for s in S:
    if s == 1:
        num_digit += 1
    else:
        print(s)
        break
        
    if num_digit >= K:
        print(s)
        break

Submission status: Accepted

Solution code:
import sys
s = input()
n = int(input())
cnt = 0
if n == 1:
	print(s[0])
	sys.exit()
for i in s:
	if i == '1':
		cnt += 1
	else:
		break
if n <= cnt:
	print(1)
	sys.exit()
	
for i in s:
	if i != '1':
		print(i)
		sys.exit()
print(1)

Submission status: Accepted

Solution code:
s = input().rstrip()
k = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(1)
else:
	print(b)

Submission status: Accepted

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

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

print(1)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
Flag = True
for T in range(0,min(K,len(S))):
    if S[T]!='1':
        Disp = S[T]
        Flag = False
        break
if Flag: print('1')
else: print(Disp)

Submission status: Accepted

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