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 = list(str(input()))
n = int(input())
c = 0
for i in range(len(s)):
    if int(s[i]) == 1:
        c = c + 1
        if c == n:
            print(1)
            break
    else:
        print(s[i])
        break

Submission status: Accepted

Solution code:
# 2019/04/01
# AtCoder Beginner Contest 106 - C

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

onecnt = 0

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

if k > onecnt:
    print(second_str)
else:
    print("1")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor, pow
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
S = ""
K = 0


def set_inputs():
    global S, K
    S = get_str()
    K = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    x = next(itertools.dropwhile(lambda i: i < len(S) and S[i] == "1", itertools.count(0)))
    if K - 1 < x:
        print("1")
        return
    print(S[x])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solve(s, k):
    n = 0
    for c in s:
        if c != '1':
            break
        n += 1

    if k <= n:
        return '1'
    else:
        return s[n]

main()

Submission status: Accepted

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

for x in N[:min(len(N), K)]:
  if x=='1':
    pass
  else:
    print(x)
    break
else:
  print('1')

Submission status: Accepted

Solution code:
str=input()
k=int(input())
lst=list(str)
flag=True
pos=0
for x in lst:
    if x!="1":
        flag=False
        break
    pos+=1


if flag:
    print(1)
elif k<=pos:
    print(1)
else:
    for x in lst:
        if x!='1':
            print(x)
            break

Submission status: Accepted

Solution code:
S=input()
K=int(input())
ans = ''
for i, x in enumerate(S):
    if x == '1':
        ans += x
    else:
        ans += x
        break
if len(ans)<=K:
    print(int(ans[-1]))
else:
    print(int(ans[K-1]))

Submission status: Accepted

Solution code:
s=list(input())
s=list(map(int,s))
k=int(input())
count=0
for i in range(100):
  if count==k:
    print(1)
    exit()
  if s[i]==1:
    count+=1
  else:
    print(s[i])
    exit()

Submission status: Accepted

Solution code:
s=input()
k=int(input())
on=[int(j) for j in range(2,10)]
for i in range(k):
    if int(s[i]) in on:
        print(s[i])
        break
    elif i==k-1:
        print('1')
    else:
        i+=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())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        break
    else:
        n += 1

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

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        n = i 
        break

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

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        n = i +1
        break

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

Submission status: Accepted

Solution code:
S = input()

K = int(input())

index = 0
res = ""

while K > index and index < len(S):
    if S[index] == "1":
        res = "1"
    else:
        res = S[index]
        break;
    index += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=list(input())
m=int(input())
i=0
for t in range(len(n)):
  if n[t]!="1":
    i=t+1
    break
if m<i:
  print(1)
else:
  print(int(n[i-1]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

one_count = 0
one_end = 0
for i,s in enumerate(S):
    if s=='1':
        one_count+=1
    else:
        one_end=i
        break
if one_count>=K:
    print(1)
else:
    print(S[one_end])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=list(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:
s = str(input())
k = int(input())
ans = None
for i in range(k):
    if s[i] != "1":
        ans = s[i]
        break
if ans != None:
    print(ans)
else:
    print("1")

Submission status: Accepted

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

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

if flag==1:
  print(int(num))
else:
  print(1)

Submission status: Accepted

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

print('1')

Submission status: Accepted

Solution code:
s,k=input(),int(input())
a=True
for i in s[:k]:
    if i!="1":
        print(i)
        a=True
        break
    a=False
if not a:
    print(1)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    k = I()
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            quit()
    print(1)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()

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:
S = input()
K = int(input())

if S[:K].count('1') == K:
    print(1)
else:
    for s in S[:K]:
        if s != '1':
            print(s)
            break

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
import sys
S = list(input())
K = int(input())
S = [int(i) for i in S]
count = 0
for i in range(K):
    if S[i] is not 1:
        print(S[i])
        sys.exit()
    else:
        count+= 1
if count == K:
    print(1)

Submission status: Accepted

Solution code:
s = raw_input()
k = int(raw_input())
count = 0
for n in s:
	count += ((int(n)**5)**10)**12
	if count>=k:
		print n
		break

Submission status: Accepted

Solution code:
S = input()
K = int(input())
init1 = -1

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
def one_checker(s,k):
    for i in range(k):
        if s[i] != '1':
            return s[i]
    return '1'
result = one_checker(s,k)
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2wa

s = list(input())
k = int(input())
for ki in range(k):
    if s[ki] != "1":
        print(s[ki])
        exit()
print(1)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
""" 
if s[0]=='1':
    print(s[0])
else:
"""
one_num=0

for i in range(len(s)):
    if s[i]=="1":
        one_num+=1
    else:
        break
if k<=one_num:
    print(1)#1 s[0]

elif one_num==0:
    #no one
    print(s[0])#2~9

else: #k>one_num
    print(s[one_num])

Submission status: Accepted

Solution code:
S=input()
K=int(input())
if S[0]!='1':
    print(S[0])
else:
    flag=True
    for i in range(len(S)):
        if S[i]!='1':
            if K<=i:
                print('1')
            else:
                print(S[i])
            flag=False
            break
    if flag:
        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())
for s in S:
    if int(s) == 1:
        K -= 1
        if K == 0:
            print(s)
            exit()
    else:
        print(s)
        exit()

Submission status: Accepted

Solution code:
S =input()
K = int(input())
L = 0
for i in range(len(S)):
    if K == i + 1:
        print(S[i])
        break
    y = int(S[i])
    if y != 1:
        print(y)
        break

Submission status: Accepted

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

count = 0
flag = 0

for s in S:
    if s == '1' :
        count += 1
    else:
        ans = s
        break
            
if K <= count :
    print(1)
else:
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i,c in enumerate(s):
	if c!='1':
		break # if j<i: s[j]=='1' else: s[j]!='1'
else:
	i = float('inf')

if k-1<i:
	print('1')
else:
	print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

S = I()
K = I()

if len(list(set(str(S)))) == 1:
    print(str(S)[0])
    exit()

first_non_one_number = None
for idx, i in enumerate(str(S)):
    if i != '1':
        first_non_one_number = idx
        break

if K-1 < first_non_one_number:
    print(1)
    exit()
else:
    print(str(S)[first_non_one_number])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

mark = 0
cnt = 0
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()
    else:
        cnt += 1
        if K == cnt:
            print('1')
            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())
ans = 1
for i in range(min(len(S), K)):
  if S[i] == '1':
    continue
  else:
    ans = int(S[i])
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

    print(1)
    return


main()

Submission status: Accepted

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

Submission status: Accepted

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


def solve(S: str, K: int):
    S = list(map(lambda c:int(c), S))
    for i in range(len(S)):
        #print("i = {}".format(i))
        if S[i] == 1 and i+1 == K:
            print(1)
            break
        elif S[i] != 1:
            print(S[i])
            break
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
start = 0
for i in range(len(s)):
    c = s[i]
    if c!='1':
        start = i
        break

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

Submission status: Accepted

Solution code:
def to_infinity(S: str, K: int) -> str:
    """5000兆 = 5e15 であり、文字 n は 5e15 日後には n^(5e15) の長さになっている。
    これは 2^100 = 10^30 より、K の範囲には確実に収まらない。
    """
    if K == 1:
        return S[0]
    # K > 1
    if len(S) == 1:
        return S[0]
    # K > 1 and |S| > 1
    for k in range(K):
        if k >= len(S):
            return '1'
        if S[k] != '1':
            return S[k]
    return '1'


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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
flag = True
num = 0
ans = ''
for k in range(len(S)):
    if flag and S[k] == '1':
        num += 1
    else:
        flag = False
    if S[k] != '1':
        ans = S[k]
        break
if num >= K:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a = 0
b = 0

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

if K <= a:
    print(1)
else:
    print(b)

Submission status: Accepted

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

import itertools
import collections
import bisect

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(map(int, 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:
for i in input()[:int(input())]:
    if i!="1":    break
print(i)

Submission status: Accepted

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

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

if k <= i:
    print(1)
else:
    print(n[i])

Submission status: Accepted

Solution code:
st=list(input())
kn=int(input())

def ans(s,k):
    if len(s)>=k:
        for i in range(k):
            if s[i]!="1":
                return s[i]
        return 1
    else:
        for i in range(len(s)):
            if s[i]!="1":
                return s[i]
print(ans(st,kn))

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 k>cnt:
    print(s[cnt])
else:
    print(1)

Submission status: Accepted

Solution code:
def solve(string):
    s, k = string.split()
    for _s in s[:int(k)]:
        if _s != "1":
            return _s
    else:
        return "1"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
def solve(string):
    s, k = string.split()
    if len(s) == 1:
        return s
    k = int(k)
    for _s in s[:k]:
        if _s != "1":
            return _s
    else:
        return "1"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
def solve(string):
    s, k = string.split()
    counter = 0
    for _s in s:
        if _s == "1":
            counter += 1
            continue
        break
    return s if len(s) == 1 else "1" if int(k) <= counter else s[counter]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
def solve(string):
    s, k = map(int, string.split())
    counter = 0
    for _s in str(s):
        if _s == "1":
            counter += 1
            continue
        break
    return str(s) if len(str(s)) == 1 else "1" if k <= counter else str(s)[counter]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

Solution code:
def solve(string):
    s, k = string.split()
    if len(s) == 1:
        return s
    counter = 0
    for _s in str(s):
        if _s == "1":
            counter += 1
            continue
        break
    return "1" if len(k) < 4 and int(k) <= counter else s[counter]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Accepted

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

ans = solve()
print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
result = ''
for i in S[:K]:
  if i != '1':
    result = i
    break
else:
    result = '1'

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

if len(S) >= int(K):
    if set(S[:int(K)]) == set(['1']):
        print('1')
        exit()

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

Submission status: Accepted

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

for i in range(len(s)):
    if s[i]!=1:
        ans=s[i]
        break
    else:
        num+=1
        if num==k:
            ans=s[i]
            break
        else:
            pass

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if len(S)==1:
  print(s)
elif K<=one_sq:
  print(1)
else:
  print(S[one_sq])

Submission status: Accepted

Solution code:
S=input()
K=int(input())
tnum=1
for k in range(K):
    if S[k]=="1":
        tnum=1
    else:
        tnum=int(S[k])
        break
print(tnum)

Submission status: Accepted

Solution code:
seq=input()
k=int(input())
ans=0
con=0
for i in seq:    
    if i!="1":
        ans=i
        break
    con+=1
if con>=k:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
k=int(input())
ans='1'
#k=min(k,len(S))
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())

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

Submission status: Accepted

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

n = 0 # First index of a number that is not equal to 1
for s in S:
    if s=='1':
        n += 1
    else:
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

# assert solve('111', 1) == 1
# assert solve('111', 2) == 1
# assert solve('111', 3) == 1

# assert solve('12', 1) == 1
# assert solve('12', 2) == 2
# assert solve('12', 100) == 2

# assert solve('21', 1) == 2
# assert solve('21', 2) == 2
# assert solve('21', 100) == 2

# assert solve('121', 1) == 1
# assert solve('121', 2) == 2
# assert solve('121', 3) == 2
# assert solve('121', 100) == 2

# assert solve('1121', 1) == 1
# assert solve('1121', 2) == 1
# assert solve('1121', 3) == 2
# assert solve('1121', 100) == 2

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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