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:
import sys
input = sys.stdin.readline

def main():
    s = "0" + input()
    k = int(input())
    for i in range(1, len(s)):
        if s[i] != "1":
            print(s[i])
            break
        else:
            if i == k:
                print(1)
                break

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
ans = 1
for (offset, item) in enumerate(S):
    if item != '1':
        ans = int(item)
        break
    elif offset == K-1:
        ans = 1
        break
print(ans)

Submission status: Accepted

Solution code:
s = list((input()))
k = int(input())
if "1" in s:
	flag = True
	if k > len(s):
		k = len(s)
	for i in range(k):
		if s[i] != "1":
			if flag:
				p = int(s[i])
			flag = False
	if flag:
		print(1)
	else:
		print(p)
else:
	print(int(s[0]))

Submission status: Accepted

Solution code:
n = input()
k = int(input())
if len(n) > 1:
  for i in range(k):
    if n[i] is not '1':
      print(n[i])
      exit()
print(n[0])

Submission status: Accepted

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


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


ans = "1" if K-1 < i else S[i]
print(ans)

Submission status: Accepted

Solution code:
s=[i for i in input()]
k=int(input())
if len(list(set(s[:min(k,len(s))])))==1 and s[0]=="1":
    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())
count = 0
ans = 0
for i in range(len(s)):
    if s[i] == "1":
        count += 1
        if count == k:
            ans = 1
            break
    else:
        ans = s[i]
        break
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
s.append(-1)
i=0
ans=-1
while True:
    if s[i]=="-1":
        ans=s[i]
        break
    if s[i]!="1":
        ans=s[i]
        if i+1>k:
            ans="1"   
        break
    i+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
tmp = 1
t = len(s)
for i in range(len(s)):
    if s.find("1")!=0:
        tmp=s[0]
        t = i
        break
    s = s[1:]
if k > t:
    print(tmp)
else:
    print("1")

Submission status: Accepted

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

print(out)

Submission status: Accepted

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

S = [int(v) for v in input().strip()]
N = int(input())

for i in range(len(S)):
    v = S[i]
    
    if v == 1:
        if i + 1 == N:
            print(v)
            exit()
    else:
        print(v)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for c in S:
    if c != '1':
        print(c)
        exit()
    else:
        K -= 1
        if K == 0:
            print('1')
            exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

solve()

Submission status: Accepted

Solution code:
S = list(map(int, list(input())))
K = int(input())
result = 0
if len(S) < K:
    for s in S:
        if s != 1:
            result = s
            print(s)
            exit(0)
else:
    for s in S[:K]:
        if s != 1:
            result = s
            print(s)
            exit(0)
print(1)

Submission status: Accepted

Solution code:
import re

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

if not re.search(r'[^1]',S):
  print(1)
elif re.search(r'[^1]',S).start() >= K:
  print(1)
else:
  print(S[re.search(r'[^1]',S).start()])

Submission status: Accepted

Solution code:
s=input()
k=int(input())
cnt=0
for i in s:
  if i=="1":
    cnt+=1
  else:
    a=i
    break
print(1 if cnt>=k else a)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
f=0
for i in range(k):
  if s[i]!='1':
    x=s[i]
    f=1
    break
print(x) if f==1 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()
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
c=0
a='1'
while c<K:
 if S[c]!=a:
  a=S[c]
  break
 c+=1
print(a)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    s = S[i]
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
 
if K == 1:
    print(S[0])
    exit()
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<=len(S):
    if S[:K]=="1"*K:
        print(1)
    else:
        print(S.replace("1","")[0])
else:
    print(S.replace("1","")[0])

Submission status: Accepted

Solution code:

S = input()

K = int(input())


for i in range(K):

    if S[i] != "1":
        ans = S[i]
        break

    elif i == K - 1:
        ans = "1"

print (ans)

Submission status: Accepted

Solution code:
# 混乱する

s = input()
k = int(input())
for i, v in enumerate(s):
    if int(v) > 1 and i+1 <= k:
        print(v)
        exit()
print(1)

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

Submission status: Accepted

Solution code:
from sys import stdin
S = (stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
cnt = 0
for i in S:
    if i == "1":
        cnt += 1
    else:
        ans = int(i)
        break
if cnt >= K:
    ans = 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
 
k = min(K,len(S))

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

i=0
while i<=len(S)-1:
    if S[i]=="1":
        i+=1
    else:
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())
k = int(input())
li = [int(k) for k in list(str(s))]
#print(li)
count = 0
for i in li:
  if i ==1:
    count+=1
  else:
    ans = i
    break
    
if k <= count:
  print(1)
else:
  print(ans)

Submission status: Accepted

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

ans_idx = 0

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

Submission status: Accepted

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

for i in range(len(s)):
    if s[i]!='1':
        count = min(i,count)

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
first=0
for i in range(n):
  if s[i]!='1':
    first=i
    break
k=int(input())
if s[0]!='1':
  print(s[0])
elif first>=k:
  print(1)
else:
  print(s[first])

Submission status: Accepted

Solution code:
S=input()
K=int(input())
c = 0
for s in S:
    c += 1
    if s != '1':
        break
        
if K < c:
    print('1')
else:
    print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc(S, K):
    if (K == 1):
        return S[0]

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

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

    print(calc(S, K))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

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

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

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  n=I()

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

  return 1

print(main())

Submission status: Accepted

Solution code:
S = input()
k = int(input())
flag = False
pre = 0
cans = 0

for s in S:
    bit = format(5000000000000000-1,"b")
    temp = int(s)
    ans = 1
    for i in bit[::-1]:
        temp = (temp**2)
        if i == "1":
            ans *= temp
        if cans + ans >= k:
            print(s)
            flag = True
            break
    cans += ans
    if flag:
        break

Submission status: Accepted

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

c = 0
for s in S:
    c += 1
    if s != '1':
        break

if K < c:
    print('1')
else:
    print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC106C - To Infinity
s = input()
k = int(input())
flg = False
for i in s[:k]:
    if i != "1":
        print(i)
        flg = True
        break
if not flg:
    print(1)

Submission status: Accepted

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

l = min(K,len(S))
if S[:l] == "1"*l :
    ans = "1"
else :
    for s in S :
        if s != "1" :
            ans = s
            break

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
scope = 0
for s in S:
    if int(s) == 1:
        scope += 1
        if scope >= K:
            print(s)
            break
    else:
        print(s)
        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:
    break
print(S[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 0
while i < len(S) and S[i] == '1':
    i += 1
if K <= i or i == len(S):
    print(1)
else:
    print(S[i])

Submission status: Accepted

Solution code:
k = input()
s = int(input())
ls = []
for i in k:
    ls.append(int(i))
    
if set(ls[0:s]) == {1}:
    print(1)
else:
    flg = 1
    for i in ls:
        flg = int(i)
        if flg !=1:
            break
    print(flg)

Submission status: Accepted

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

from math import *
from itertools import *
from collections import *


if __name__ == '__main__':
    s = ' ' + input()
    k = int(input())

    i = 1
    j = 1
    while j < len(s) and s[i] == s[j]:
        j += 1
    if k >= j and s[i] == '1':
        print(s[j])
    else:
        print(s[i])

Submission status: Accepted

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

max_s = 1

for string in s[:k]:
    if int(string) > max_s:
        max_s = int(string)
        break

print(max_s)

Submission status: Accepted

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

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

Submission status: Accepted

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

if K == 1:
    print(S[0])
    exit()
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())

i = 0

while s[i] == '1' and i < k-1:
  i += 1

print(int(s[i]))

Submission status: Accepted

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

a = 0
i = 0

while a < k:
  a += min(s[i]**70, k)
  i +=1

print(s[i-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# コメントの解き方だとTLE
# after = 5*10**15

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

'''part = 0

for i in s:
  i = int(i)
  part += i**after
  if k <= part:
    print(i)
    break'''

s_k = s[:k]
sk1_count = s_k.count('1') 

if sk1_count == k:
  print(1)
else:
  for i in s:
    i = int(i)
    if i != 1:
      print(i)
      break

Submission status: Accepted

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

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

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

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:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
	
def main():
	S = input()
	S = list(S)
	K = int(input())
	
	if len(S) == 1:
		print(S[0])
		sys.exit()
		
	tmp = -1
	for i, val in enumerate(S):
		if int(val) != 1:
			tmp = int(i)+1
			break
	
	if K >= tmp:
		print(S[tmp-1])
	else:
		print(1)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
n=list(input())
k=int(input())
if len(n)==1 and n[0]=='1':
  print('1')
else:
  one_list=[]
  while len(n)!=0:
    if n[0]=='1':
      one_list.append(n.pop(0))
    else:
      break
  if k<=len(one_list):
    print('1')
  else:
    print(n[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [int(i) for i in str(input())]
K = int(input())

k = 1
for i in range(len(S)):
    if S[i] == 1:
        if k < K:
            k += 1
            continue
        else:
            print(1)
            exit()
    else:
        print(S[i])
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
Sの文字列、最初が何かに依存しそう
"""


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

if S[0] == "1":
    len_one = 0
    flag = 0
    for s in S:
        if s == "1" and flag == 0:
            len_one += 1
        elif flag == 0:
            save_num = s
            flag = 1
        else:
            flag = 1
    if K <= len_one:
        ans = 1
    else:
        ans = int(save_num)

else:
    ans = int(S[0])

print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
while S[0] == '1' and len(S) > 1 and K > 1:
    S = S[1:]
    K -= 1
print(S[0])

Submission status: Accepted

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

flag = 1
i = -1

while (flag == 1) : 
    i += 1
    
    if N[i] == 1 : 
        if K > 1 : 
           K = K -1
        else : 
            print(1)
            flag = 0
    else : 
        print(N[i])
        flag = 0

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    k = f()[0]

    slen = len(s)
    for i in range(k):
        if s[i] != '1':
            print(s[i])
            return
    
    print(1)
    

solve()

Submission status: Accepted

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


def solve(S: str, K: int):
    onelen = len(list(takewhile(lambda x:x=="1",S)))
    res = "1" if onelen >= K else S[onelen]
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve(S: str, K: int):
    for i,s in enumerate(S):
        if s != "1":
            print(s)
            return
        elif i == (K - 1):
            print(s)
            return
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = 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())


check = 0

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


print('1')

Submission status: Accepted

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

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

if k <= cnt:
    print(1)
else:
    print(first_number)

Submission status: Accepted

Solution code:
from sys import stdin

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

for x in range(len(S)):
    if int(S[x]) > 1:
        print(S[x])
        break
    if K == x + 1:
        print('1')
        break

Submission status: Accepted

Solution code:
S = input()
K = int(input())
if len(S) == 1:
    print(S)
else:
    ind = 0 
    while True:
        if S[ind] != '1':
            break
        ind += 1
        if ind == len(S):
            break
    if K <= ind:
        print('1')
    else:
        print(S[ind])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - To Infinity
https://atcoder.jp/contests/abc106/tasks/abc106_c

"""
import sys

def solve(S, K):
    leading_1 = 0
    infinity_ch = '@'
    for s in S:
        if s == '1':
            leading_1 += 1
        else:
            infinity_ch = s
            break
    if K <= leading_1:
        return '1'
    else:
        return infinity_ch


def main(args):
    S = input()
    K = int(input())
    ans = solve(S, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if len(S) < K:
    for s in S:
        if s != '1':
            print(s)
            exit()
    print(1)
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())

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

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


def main():
    count = 0

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

        count += 1
        if count == K:
            return '1'


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

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

#go = 5000000000000000
C = '1'
for i in range(len(S)):
    if S[i] != '1' or i+1 == K:
        C = S[i]
        break
print(C)

Submission status: Accepted

Solution code:
li = [ int(it) for it in input()]
K = int(input())


big = 1e19

def pows(v,p):
  _p = p
  r = 1
  t = v
  for i in range(100000):
    if (r>big):
      return big
    if (_p%2)==1:
      r *= t
    _p//=2
    if (_p==0):
      return r
    t **= 2

m = 0
for it in li:
  m += pows(it,5000000000000000)
  if (m>=K):
    print (it)
    break

Submission status: Accepted

Solution code:
import re

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

n1 = re.search("[2-9]", S)
if not n1:
	print("1")
	exit()

n1i = n1.start()
print(S[min(n1i, K - 1)])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    s = input()
    k = intin()

    for i, c in enumerate(s):
        if i + 1 >= k:
            print(c)
            return
        if c != '1':
            print(c)
            return

    print(s[-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = 0
a = 1
for si in s:
    if si == "1":
        c += 1
    else:
        a = si
        break

print("1" if k - c <= 0 else a)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys

S = [int(x) for x in input()]
K = int(input())

for s in S[:K]:
    if s != 1:
        print(s)
        sys.exit()
print(1)

Submission status: Accepted

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


def main():
    for i, s in enumerate(S):
        if s != '1':
            if K > i:
                print(s)
            else:
                print(1)
            return
    print(1)


main()

Submission status: Accepted

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

#print (S)
i = 0
for i in range(K):
    if int(S[i]) > 1:
        print (int(S[i]))
        sys.exit()
print (int(S[K-1]))