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 = [int(c) for c in input()]
K = int(input())

if sum(S) == len(S):
    print(1)
    exit()

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

left_one_count = 0
first_char_not_one = ""
for c in S:
    if c == "1":
        left_one_count += 1
    else:
        first_char_not_one = c
        break

if left_one_count >= K:
    print("1")
else:
    print(first_char_not_one)

Submission status: Accepted

Solution code:
def c_to_infinity(S, K):
    ans = '1'
    for s in S[:K]:
        if s != '1':
            ans = s  # 現れた数字が5000兆回の操作によってK文字目に必ず現れる
            break
    return ans

S = input().strip()
K = int(input())
print(c_to_infinity(S, K))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def main9():
    buf = input("");
    buf2 = int(input(""));
    result = 1;
    for i in range(buf2):
        if buf[i] != '1':
            result = int(buf[i]);
            break;
    print(result);


if __name__ == '__main__':
    main9()

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
while i < k:
	if s[i] != "1":
		break
	i += 1

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

Submission status: Accepted

Solution code:
def solve(k,s):
    isOne = True
    index = 0
    digit = -1
    while index<len(s):
        if s[index] == "1":
            index += 1
        else:
            digit = s[index]
            break
    if digit != -1:
        if k <= index:
            return(1)
        else:
            return(digit)
    else:
        return(1)

s = input()
k = int(input())
print(solve(k,s))

Submission status: Accepted

Solution code:
from math import *
s=str(input())
arr=[]
for i in range(len(s)):
    arr.append(int(s[i]))
n=int(input())
val=n
i=0
ans=1
flag=0
while(flag==0):
    ans=ans*arr[i]
    if(s[i]=='1'):
        if(val==1):
            flag=1
            break
        else:
            val-=1
    else:
        if(log(val,ans)<=pow(10,15)*5):
            flag=1
            break
    i+=1
print(arr[i])

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:
        tail = s[i]
        break
if k > cnt:
    print(tail)
else:
    print("1")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
k=int(input())
count=0
for i in a:
    if i=='1':count+=1
    else:break
if count>=k:print(1)
else:print(a.replace('1','')[0])

Submission status: Accepted

Solution code:
s=input()
k=int(input())
for i,num in enumerate(s):
    num=int(num)
    if num ==1:
        if i != k-1:
            continue
        print(1)
        break
    print(num)
    break

Submission status: Accepted

Solution code:
# coding:utf-8

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:
numl=list(input())
k=int(input())
rs=0
for i in range(k):
    if not numl[i]=="1":
        print(int(numl[i]))
        rs=0
        break
    else:
        rs=1
if rs==1:
    print(1)

Submission status: Accepted

Solution code:
#abc106c
import sys

s=raw_input()
k=int(raw_input())
if s.count('1')==len(s):
 print '1'
 sys.exit()
for i in xrange(k):
 if s[i]!='1':
  print s[i]
  sys.exit()
print '1'

Submission status: Accepted

Solution code:
import math
S = input()
K = int(input())
M = 5 * 10 ** 15

def main():
    sum = 0
    for s in S:
        n = int(s)
        sum += (M - 1) * math.log(n)
        if sum >= math.log(K):
            print(n)
            return

def main2():
    if K <= len(S):
        for i in range(K):
            if S[i] != '1':
                print(S[i])
                return
        print('1')
        return
    else:
        for s in S:
            if s != '1':
                print(s)
                return

if __name__ == '__main__':
    main2()

Submission status: Accepted

Solution code:

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

slist = list(s)
i = 0
count = 0
while slist[i] == "1":
    count += 1
    i += 1
    if i >= len(slist):
        break
    
if count >= k:
    print(1)
else:
    print(slist[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

def prefixlen(s, c):
    """文字列sの文字cのみからなる接頭辞の長さ"""
    count = 0
    for x in s:
        if x != c: break
        count += 1
    return count

l = prefixlen(S, '1')
print(S[l] if l < K else '1')

Submission status: Accepted

Solution code:
count = 0

s_chars = input()
k_num = int(input())

for i in s_chars:
    if i == '1':
        count += 1
    else:
        break

if s_chars[0] != '1':
    print(s_chars[0])
else:
    if count >= k_num:
        print(s_chars[k_num - 1])
    else:
        print(s_chars[count])

Submission status: Accepted

Solution code:
n=input()
k=int(input())
for i in range(k):
  if n[i] != "1":
    print(n[i])
    exit()
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])
        exit(0)
print(1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=input()
if len(s)<2:
  print(s)
  exit()
k=int(input())
for t in s[:k]:
  if t!='1':
    print(t)
    break
else:
  print(1)

Submission status: Accepted

Solution code:
s = input()
k = int(input()) - 1
i = 0
while i < k and s[i] == '1':
    i += 1
print(s[i])

Submission status: Accepted

Solution code:
s=input()
k=int(input())
count=0
for one in s:
  if one=="1":
    count+=1
  else:
    break
print(int(s.replace("1","")[0]) if k>count else 1)

Submission status: Accepted

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


def ans():
    if len(S) == 1:
        return S
    else:
        for i in range(len(S)):
            if i + 1 == k:
                return S[i]
            if S[i] != '1':
                return S[i]

    return 1


print(ans())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    s = input()
    target_index = int(input()) - 1

    for char in s[:target_index + 1]:
        if char == '1':
            continue
        else:
            print(char)
            return

    print('1')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = '1'
i = 0
while i < k and i < len(s):
	if s[i] != '1':
		ans = s[i]
		break
	i = i + 1

print ans

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    output = solve(S, K)
    print(output)
    return

def solve(S, K):
    """
    解答のコード
    """
    for i in range(K):
        if S[i] != "1":
            return S[i]
    return "1"

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    output = solve(S, K)
    print(output)
    return

def solve(S, K):
    if K <= len(S) and S[:K] == "1"*K:
        # 文字列の1番目からK番目までがすべて1だった場合、
        # それ以降の文字列に1以外の数字があっても1が答え
        return "1"
    for s in S:
        if not s == "1":
            return s  # Sの"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])
        exit()

print('1')

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

# S = "111111111"
# K = 6565

ans = 1
ones = -1

for i in range(len(S)):
    if int(S[i]) == 1:
        pass
    else:
        ans = int(S[i])
        ones = i
        break

if ones == -1:
    ones = len(S) + 1

if K <= ones:
    ans = 1

print(ans)

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
# coding: utf-8

s,k = [ input() for i in range(2) ]

count = 0
while count != len(s) and s[count]=="1":
    count += 1

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

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())
for i in range(K):
    if i == K-1:
        print(S[i])
        break
    elif S[i] !='1':
        print(S[i])
        break

Submission status: Accepted

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

while s[0] == "1" and len(s) >= 2:
    del s[0]
    o += 1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#C
S = input()
K = int(input())
counter = 0
for i in S:
    if i == '1':
        counter += 1
    else:
        break
if K <= counter:
    print(1)
else:
    print(S[counter])

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))
k = int(input())
total = 0
for i in range(len(s)):
    total += pow(s[i], 5000)
    if total >= k:
        print(s[i])
        break

Submission status: Accepted

Solution code:
# encoding: utf-8
S = input()
K = int(input())

# confirm that 2 ** (5000 tri.) = (1024) ** (15 * 10 ** 14) >> 10 ** 18 >= K
tmp = 1
for i in range(5000 * (10 ** 12)):
    tmp = tmp << 1
    if tmp > K:
        for idx, si in enumerate(S):
            if si != "1": break
        # take care of 1
        if K <= idx: print(1)
        else: print(si)
        # end
        break
else:
    # not implemented
    print("WA")

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=str(input())
K=int(input())
for i in range(K) :
#    print("checking "+S[i])
    if S[i]!="1" :
        break
print(S[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
n = 5*(10**15)
for x in s:
    if x=='1':
      k -= 1
      if k==0:
      	print(1)
      	break
    else:
      print(x)
      break

Submission status: Accepted

Solution code:
S = list(map(int,input()))
K = int(input())
ans = 1
if K == 1 or S.count(S[0]) == len(S) or S.count(1) == len(S):
    ans = S[0]
else:
  for x in range(K):
    if S[x] != 1:
      ans = S[x]
      break
print(ans)

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(S[K-1])

Submission status: Accepted

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

#A = int(l[0])


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

i =int(S)
v_1 = []
#cnt = []
while i > 0:
    v_1.append( i % 10 )
    #cnt.append(1)
    i //= 10 # 必須
v_1.reverse()

length_n = 0
target_v_num = 0

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


print(V)

Submission status: Accepted

Solution code:
# coding: utf-8

def getLoop(S, K):
    if len(S) > K:
        return K
    if len(S) <= K:
        return len(S)

def solve(S, K):
    SList = [int(x) for x in S]
    for i in range(getLoop(S, K)):
        if SList[i] != 1:
            return SList[i]
    return 1
    
if __name__ == "__main__":
    S = input()
    K = int(input())
    print(solve(S, K))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
con1=0
ans=0
for c in s:
    if c!='1':
        ans=int(c)
        break
    con1+=1
else:
    ans=1
if k==1:
    ans=int(s[0])
if k<=con1:
    ans=1
print(ans)

Submission status: Accepted

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

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

print(tmp)

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)


def main():
    s = S()
    k = I()
    l = 0
    for c in s:
        if c != '1':
            break
        l += 1
    if l >= k:
        return 1
    return s[l]



print(main())

Submission status: Accepted

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

ans = 1
i = 0

while i < k and i < len(s):
    if s[i] != '1':
        ans = s[i]
        break
    i += 1

print(ans)

Submission status: Accepted

Solution code:
S=input()
K=int(input())
a=0
for j in S:
	a=a+1
	if j!='1':
		print(j)
		break
	if a==K:
		print('1')
		break

Submission status: Accepted

Solution code:
S=input();K=int(input())-1;p=0
while'1'==S[p]and K:K-=1;p+=1
print(S[p])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
a=0
b=0
N=len(S)
for i in range(N):
    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:
#let
S = input()
K = int(input())
tmp = S.replace("1", "")

#var
i = 0

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

print(1 if K - 1 < i else tmp[0])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
one = 0
two = ''
for c in s:
    if c=='1':
        one += 1
    else:
        two = c
        break
if k<=one:
    print(1)
else:
    print(two)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i, c in enumerate(s):
    if i == k - 1:
        print(c)
        exit()
    if c != '1':
        print(c)
        exit()

Submission status: Accepted

Solution code:
import numpy as np

s = input()
k = input()

for i, str in enumerate(s, 1):
    if str != "1":
        print(str)
        exit()

    if i == int(k):
        print(1)
        exit()

Submission status: Accepted

Solution code:
# coding: utf-8

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

ans = list(str(S))

for i in range(len(ans)):
    if int(ans[i]) != 1:
        break
if i + 1 <= K:
    print(ans[i])
else:
    print(1)

Submission status: Accepted

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

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

if K <= r:
    result = "1"
else:
    result = c

print(result)

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(0)
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
co=0	
a=0
for j in S:
	a=a+1
	if j!='1':
		print(j)
		co=1
		break
	if a==K:
		break
if co==0:
	print('1')

Submission status: Accepted

Solution code:
def solv(S):
    for i in range(0, len(S)):
        if S[i] != '1':
            return i
    return -1


S = input()
K = int(input())
ans = solv(S)
if ans == -1:
    print(1)
elif ans + 1 > K:
    print(1)
else:
    print(S[ans])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

first = '1'
threshold = float('inf')
for i in range(len(s)):
    if s[i] != '1':
        first = s[i]
        threshold = i
        break

if k - 1 < threshold:
    print(1)
else:
    print(first)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def c_to_infinity(S, K):
    for k in range(K):
        if S[k] != '1':
            return S[k]
    return '1'

S = input().strip()
K = int(input())
print(c_to_infinity(S, K))

Submission status: Accepted

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

Submission status: Accepted

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

for k_i in range(k):
    if s[k_i] != "1":
        print(s[k_i])
        exit()
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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

S = str(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:
def func(N, K):
    for n in range(len(N)):
        if N[n] != '1':
            if K > n:
                return N[n]
    return 1

print(func(input(), int(input())))

Submission status: Accepted

Solution code:
from math import pow
s = input()
k = int(input())

char = [ss for ss in s]


res = '1'

_sum = 0
for i in range(k):
    if s[i] != '1':
        res = s[i]
        break

print(res)

Submission status: Accepted

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

def func(N, K):
    for n in range(len(N)):
        if N[n] != 1:
            if K > n:
                return N[n]
    
    return 1

print(func(N, K))

Submission status: Accepted

Solution code:
S=input()
K=int(input())
a=0
b=0
N=len(S)
for i in range(N):
    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:
s = input()
k = int(input())
for i in range(0,len(s)):
    if s[i] == "1":
        k -= 1
    else:
        k = 0
    
    if k <= 0:
        print(s[i])
        break

Submission status: Accepted

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

Submission status: Accepted

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

for i, k in enumerate(range(K)):
    if S[k] != '1':
        print(S[k])
        break
    if i == K - 1:
        print('1')

Submission status: Accepted

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

total = 0

ans = 1

for i, c in enumerate(s, 1):
    if int(c) == 1:
        total += 1
    else:
        ans = c
        break
    if str(i) == k:
        break

print(ans)

Submission status: Accepted

Solution code:
def main():
    """
    Si: '1' to '9'
    1 <= |S| <= 100
    1 <=  K  <= 10^18

    5000兆: 5_000_000_000_000_000
        5 * 10^15
    """
    S = input()
    K = int(input())
    ans = f(S, K)
    print(ans)


def f(S, K):
    """
    10^18 <<<<<<<<<<<< 2^(5 * 10^15)
    """
    ans = "1"
    for i, c in enumerate(S, 1):
        if c != "1":
            return c
        elif i == K:
            return "1"

    return ans


def NG(S, K):
    """
    1: 不変
    2: 2^d
        day0: 2
        day1: 22
        day2: 2222
        day3: 22222222
    """
    import datetime
    day = 5 * (10 ** 15)
    ls = {1: 1}
    for i in range(2, 9+1):
        ls[i] = i ** day
        print(i, datetime.datetime.now())

    idx = 1
    for c in S:
        idx += ls[c]
        if idx >= K:
            return c


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
K=int(input())
l=len(S)
r=0
q=-1
if l==1:
    print(int(S))
else:
    for i in range(0,l-1):
        if int(S[i]) != 1:
            r=int(S[i])
            q=i
            break
    if q>=K or q==-1:
        print(1)
    else:
        print(r)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
 
one = True
for i in range(K):
  if S[i] != "1":
    print(int(S[i]))
    one = False
    break
if one:
  print(1)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

#5 sen tyou = 5 * (10 ** 15)

co = 0
for i in s:
    co += 1
    if i == "1":
        if k == co:
            print(1)
            break
        else:
            continue
    else:
        print(int(i))
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for c in s:
    if (int(c) > 1):
        print(c)
        break
    k -= 1
    if k <= 0:
        print(c)
        break

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a=[]
while S !=0:
  s=S%10
  a.append(s)
  S //=10
m=0

for i in range(1,len(a)+1):
  if a[-i]!=1:
    if i>K:
      ans=1
    else:
      ans=i
    break
  else:
    ans=1

print(a[-ans])

Submission status: Accepted

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

days = 5000 * (10 ** 12)
now = 0
for i in S:
    if int(i) == 1:
        now += 1
    
    if now == K or int(i) != 1:
        print(i)
        sys.exit()

Submission status: Accepted

Solution code:
S = int(input())
K = int(input())
S_list = [int(x) for x in list(str(S))]
 
def saiki(i):
  if i == len(S_list):
    print("1")
    exit()
  if K == i:
    print("1")
    exit()
  if S_list[i] > 1:
    print(S_list[i])
    exit()
  if S_list[i] == 1:
    saiki(i+1)
 
print(saiki(0))

Submission status: Accepted

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

k = 1
while k <= K:
    if S[k-1] != "1":
        print(S[k-1])
        break
    k += 1
else:
    print(1)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
import re
s1,s2=re.match('^(1*)([2-9])?',s).groups()
if(s1 and k<=len(s1)):
  print(1)
else:
  print(s2)

Submission status: Accepted

Solution code:
S = input()
K = input()
if len(K) > 100:
    K = 110
else:
    K = int(K)


def main():
    if S[0] != '1':
        print(S[0])
        return

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

    if i == len(S) - 1:
        print('1')
        return

    if K <= i:
        print('1')
        return

    print(S[i])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    S_splited = list(map(int, list(str(S))))
    offset = 0
    day = 5 * 10**18
    for i in S_splited:
        if i == 1:
            offset += 1
            if offset >= K:
                break
            continue
        else:
            break
    print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if c>=k:
	print('1')
else:
	print(n[c])

Submission status: Accepted

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

i = 0
while k > 1:
    if s[i] == "1":
        k -= 1
        i += 1
    else:
        break
print(s[i])

Submission status: Accepted

Solution code:
S = str(input())
K = int(input())
i = 0
if S[0] == '1' and K == 1:
    print(1)
#     print('A')
elif list(map(int,list(S[:(K-1)]))).count(1) == K-1:
    print(S[K-1])
#     print('B')

elif len(S) == 1:
    print(S[0])
#     print('C')
elif S[0] != '1':
    print(S[0])
#     print('D')
else :
    while(1):
        if list(S[:(K-1)])[i] == '1':
            i = i + 1
        elif i > K:
            print(S[1])
#             print('E')
        else:
            print(list(S[:(K-1)])[i])
            break

Submission status: Accepted

Solution code:
n = input()
m = int(input())
counter = 0
for i in n:
	if int(i) == 1:
		counter += 1
	else:
		print(i)
		break
	if (counter == m):
		print (i)
		break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
s = input()
k = int(input())
index_num = 0
for i in s:
  ii = int(i)
  if ii == 1:
    index_num += 1
    if k == index_num:
      print(1)
      break
  else:
    print(i)
    break