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

c1 = 0
num = ""
for c in s:
    if c == "1":
        c1 += 1
    else:
        num = c
        break

if k <= c1:
    print("1")
else:
    print(num)

Submission status: Accepted

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

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

print(ans)

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

S = input()
K = input()
if len(S) <= int(K):
    a = len(S)
else:
    a = int(K)
for i in range(a):
    ans = S[i]
    if ans != '1':
        print(ans)
        exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
elems = map(int,list(raw_input()))
k = int(raw_input())

for v in elems:
	if v == 1: 
		k -=1
	else: k = 0
	if k <= 0:
		print v
		break

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = ''
    index = 0
    s = input().rstrip('\n')
    k = int(input())
    for i in range(len(s)):
        if s[i] != '1':
            ans = s[i]
            index = i
            break
    if ans == '' or k < index+1:
        ans = '1'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
k = int(input())

i = 0
while i < len(s) - 1:
    if i == k - 1:
        print(s[i])
        exit()
    if s[i] == "1":
        i += 1
    else:
        print(s[i])
        exit()
print(s[i])

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    r = '1'
    for i,v in enumerate(s):
        if v != '1':
            r = v
            break
    if i >= k:
        print(1)
    else:
        print(r)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

S = list(input().rstrip('\n'))
K = int(input())

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

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))
k = int(input())
ans = 1

if len(s) <= k:
    for i in s:
        if i != 1:
            ans = i
            break
else:
    for i in range(0,k):
        if s[i] != 1:
            ans = s[i]
            break

print(ans)

Submission status: Accepted

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

if len(s) == 1:
    print(s)
    exit()

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

elif s[0] != "1":
    print(s[0])
    exit()

Submission status: Accepted

Solution code:
import sys

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

for s in S[:min(len(S),K)]:
    if s=="1":
        pass
    else:
        print(s)
        sys.exit()
print(1)

Submission status: Accepted

Solution code:
def solve():
    S = input()
    K = int(input())
    for i in range(len(S)):
        if S[i] != '1':
            print(S[i])
            exit()
        elif i == K - 1:
            break
    print(1)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
ans = "1"
cnt = 0
for i in s:
    if i == "1":
        cnt += 1
    elif cnt < k:
        ans = str(i)
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

S = list(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 i in range(min(len(S),K)):
  if S[i]>="2":
    print(S[i])
    exit()
print("1")

Submission status: Accepted

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

for s_idx,s in enumerate(S):
    s=int(s)
    if s!=1:
        print(s)
        break
    elif s_idx + 1 == K:
        print(s)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= int(K) :
        print(1);
        break;

Submission status: Accepted

Solution code:
import sys
S = str(input())
K = int(input())

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

count = 0
l = 0
for i in range(len(S)):
    if S[i] == '1':
        count += 1
    else:
        break
#print(count)
    
if count < K:
    print(S[count])
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 = int(s[i])
        break
print(ans)

Submission status: Accepted

Solution code:
s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  for i in range(len(s)):
    if s[i]!=1:
      break
  if i>=k:
      print(1)
  else:
      print(s[i])
else:
  print(s[0])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def solve():
    j = 1
    for i in s:
        if i != 1:
            print(i)
            exit()
        if j==K:
            print(i)
            exit()
        j += 1
    print(1)

if __name__=="__main__":
    S = input()
    K = int(input())
#    d = 5*10**15
    s = [int(c) for c in S]
#    print(s)
    solve()

Submission status: Accepted

Solution code:
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = list(map(int, in_s()))
    N = len(S)
    K = in_n()

    one_i = -1
    for i in range(N):
        if S[i] == 1:
            one_i = i
        else:
            break

    if K <= one_i + 1:
        print(1)
    else:
        ind = min(N - 1, one_i + 1)
        print(S[ind])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
    S = str(input())
    K = int(input())

    if S[0] != '1':
        print(S[0])
        return
    else:
        for i in range(1, K):
            if S[i] != '1':
                print(S[i])
                return
            else:
                continue
        print('1')

    return

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
count = 0
for i in S:
    if i == '1':
        count += 1
    else:
        break

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

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        p=i+1
        pnum=int(s[i])
        break
    p=101

if k<p:
    print(1)
else:
    print(pnum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
rep = s.replace("1", "")
if len(rep) == 0:
  print("1")
else:
  if s.index(rep[0]) < k:
    print(rep[0])
  else:
    print("1")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = readChar()
k = readInt()
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())
ans = 1
for v in range(k):
    if  s[v] != "1":
        ans = s[v]
        break
print(ans)

Submission status: Accepted

Solution code:
#n=int(input())
#a,b,c=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
s=list(input())
k=int(input())

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
if s == '1' * len(s):
  print(1)
  exit()
for i in range(len(s)):
  if s[i] != '1':
    idx = i
    num = s[i]
    break
if idx >= k:
  print(1)
else:
  print(num)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    k = int(input())
    n = len(s)
    for i in range(n):
        if s[i] != "1":
            ans = s[i]
            break
        if i == k-1:
            ans = s[i]
            break
        if i == n-1:
            ans = s[0]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

main()

Submission status: Accepted

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


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

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

Submission status: Accepted

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

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

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:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = X()
K = i()

for i in range(K):
    if S[i] == "1":
        pass
    else:
        print(S[i])
        sys.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())

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

Submission status: Accepted

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

Submission status: Accepted

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

if s[0] > 1:
  print(s[0])
elif sum(s[0:k]) == k and len(s[0:k]) == k:
  print(1)
else:
  i = 0
  while s[i] == 1:
    i += 1
    if s[i] != 1:
      print(s[i])
      break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
if k==1 or len(s)==1:
  print(s[0])
else:
  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())

if k == 1:
    print(s[0])
else:
    count = 0
    for i, v in enumerate(s, 1):
        if v == '1':
            count += 1
        else:
            tmp = v
            break

    if count >= k or count ==len(s) :
        print(1)
    else:
        print(tmp)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
flag=True
i=0
while flag:
    if i==len(s):
        break
    elif s[i]!="1":
        res=s[i]
        flag=False
    else:
        i+=1
if k>i:
    print(res)
else:
    print(1)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    k = I()
    for i, si in enumerate(s):
        if si != '1':
            print(si)
            sys.exit()
        if i == k-1:
            break
    print(1)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if ones >= K:
    print(1)
else:
    print(v)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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


def ans():
    for i in range(K):
        if S[i] != '1':
            return S[i]

    return '1'


print(ans())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    S = input()
    K = ii()
    for i in range(min(len(S), 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())

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

print(ans)

Submission status: Accepted

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

ts=s[:k]
if ts.count('1')==len(ts):
  print(1)
  exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
count = 0
for i in s:
    if i == "1":
        count += 1
        if count == len(s):
            print(1)
            break
        else:
            pass
    else:
        if k <= count:
            print(1)
            break
        else:
            print(i)
            break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
f = True
for si in s[:k]:
    if si != "1":
        print(si)
        f = False
        break
if f: print("1")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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



num = 1


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

Submission status: Accepted

Solution code:
S = str(input())
K = int(input())
s  = ""
for i in range(len(S)):
  if(S[i]=="1"):
    s += S[i]
  else:
    s+=S[i]
    break
if(K>=len(s)):
  print(s[-1])
else:
  print("1")

Submission status: Accepted

Solution code:
S = input()
K = int(input()) - 1
    
rot = 10 ** 30 + 7

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
cnt=0
i=0
while s[i] =="1" and i<=len(s):
    cnt+=1
    i+=1
    if i==len(s):
        break

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

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()
    else:
        continue
print(1)

Submission status: Accepted

Solution code:
X=5*10**15
S = input()
k = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2^5000000000000000 > 10^135
S = list(input())
K = int(input())
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()
    elif i == K - 1:
        print('1')
        exit()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    S = readline().strip().decode()
    K = int(readline())
    if S[0] != '1':
        print(S[0])
        return 

    cnt = 0
    for i in S:
        if i == '1':
            cnt += 1
        else:
            break
    if K <= cnt:
        print('1')
    else:
        print(S[cnt])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
mem = 1
for i in S:
  if i != "1" or mem == K: 
    print(i)
    break
  mem += 1 
else: print("1")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
x=0
ans=0
while x<len(s) and s[x]=="1":
  x+=1
if x>0:
  if k<=x:
    ans=1
  else:
    ans=s[x]
else:
  ans=s[0]

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
s=int(input())
s=list(str(s))
k=int(input())
i=0
while True:
  if i==len(s):
    print(1)
    break
  if s[i]!="1":
    print(s[i])
    break
  else:
    i=i+1
  if i==k:
    print(1)
    break

Submission status: Accepted

Solution code:
s=list(map(int,list(input())))
k=int(input())
cnt1=0
for si in s:
  if si==1:
    cnt1+=1
  else:
    break
if k<=cnt1:
  print(1)
else:
  print(s[cnt1])

Submission status: Accepted

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

if set(s[:K]) == {"1"}:
	print("1")
else:
	for ss in s:
		if ss != "1":
			print(ss)
			break

Submission status: Accepted

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

k=0
for s in S:
  s = int(s)
  k += 1
  if not s == 1:
    print(s)
    sys.exit()
  elif k == K:
    print(1)
    sys.exit()

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())
flag=1
for i in range(k):
    if(s[i]!='1'):
        print(s[i])
        flag=0
        break

if(flag==1):
    print("1")

Submission status: Accepted

Solution code:
import sys

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

for i in range(len(S)):
    if i+1 <= K and S[i] != '1':
        print(S[i])
        sys.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])
      break
else:
    print(1)

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]=="1":
        k-=1
    else:
        k-=int(s[i])*(5*10**18)
    if k<=0:
        print(s[i])
        exit()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
total = 0
for n in S:
    if n == "1":
        total += 1
        if total == K:
            print(1)
            break
    else:
        print(n)
        break

Submission status: Accepted

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

    def cut(s):
        for c in s:
            yield c
            if c != '1': break

    *s, = cut(S)
    if len(s) < K:
        print(s[-1])
    else:
        print(s[K - 1])


if __name__ == '__main__':
    main()

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:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    k=int(input())
    ans=1
    # k文字目までずっと１だったらans=1
    # そうじゃないなら1以外の数で最初に出てくるやつがans
    for i in range(k):
        if s[i]!='1':
            ans=s[i]
            break
    print(ans)
resolve()

Submission status: Accepted

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

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

if s[0] != "1":
    print(s[0])
    exit()
else:
    cnt = 0
    not_1 = 0
    for i in range(len(s)):
        if s[i] == "1":
            cnt += 1
        else:
            not_1 = i
            break
    if cnt >= k:
        print(1)
        exit()
    else:
        print(s[not_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 = input()
k = int(input())
ok = True
for i in range(k):
    if s[i] != "1":
        print(s[i])
        ok = False
        exit()
if ok:
    print(1)

Submission status: Accepted

Solution code:

s = list(input())

k = int(input())

cnt = 0

if len(s) == 1:
    print(s[0])
else:
    if s[0] == "1":
        
        while s[0] == "1":
            cnt += 1
            del s[0]
            if cnt>=k:
                print(1)
                break
            
        if cnt<k:
            print(s[0])
            
    else:
        print(s[0])

Submission status: Accepted

Solution code:
s = input()+"2"
k = int(input())

for i,j in enumerate(s):
    if j != "1":
        now = i
        break

if s == "1"*len(s):
    print(1)
else:
    if k-1 < now:
        print(1)
    else:
        print(s[now])

Submission status: Accepted

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

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

Submission status: Accepted

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

one = 0

for i in range(len(S)):
  if S[i] == "1":
    one += 1
  else:
    notone = S[i]
    break
#print(one,K,notone)
if one >= K:
  print("1")
else:
  print(notone)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())
    if k >= len(s):
        for i in range(len(s)):
            if s[i] != "1":
                print(s[i])
                break
        else:
            print(1)
    else:
        for i in range(k):
            if s[i] != "1":
                print(s[i])
                break
        else:
            print(1)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
k=int(input())
counter=0
nex=0
for i in range(len(n)):
  if n[i]=='1':
    counter+=1
  else:
    nex=n[i]
    break
if nex==0:
  nex='1'
if k>counter:
  print(nex)
else:
  print(1)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    k=int(input())
    if s[0]!='1':
        print(s[0])
    else:
        cnt=0
        tugi=''
        for i in s:
            if i=='1':
                cnt+=1
            else:
                tugi=i
                break
        if cnt>=k:
            print('1')
        else:
            print(tugi)
resolve()

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:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    K = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ans

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

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

Submission status: Accepted

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

i=0
while i<K:
    if S[i]>1:
        ans=S[i]
        break
    else:
        ans=1
        i+=1
print(ans)

Submission status: Accepted

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

if K <= 100:
    # 1からK文字目まで連続した1が見つかるかを探す
    for i in range(K):
        if s[i] != 1:
            # 1ではない -> つまりこの数字
            print(S[i])
            break
    else:
        # 1が連続している -> 1
        print(1)
else:
    # 一番最初に発見した1以外の数字
    for c in s:
        if c != 1:
            print(c)
            break