Problem:


﻿Score: 300 points

Problem Statement

Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:

Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.

For example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.
You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?

Constraints

S is a string of length between 1 and 100 (inclusive).

K is an integer between 1 and 10^{18} (inclusive).

The length of the string after 5 \times 10^{15} days is at least K.

Input

Input is given from Standard Input in the following format:

S
K

Output

Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.

Sample Input 1

1214
4

Sample Output 1

2

The string S changes as follows:  

Now: 1214

After one day: 12214444

After two days: 1222214444444444444444

After three days: 12222222214444444444444444444444444444444444444444444444444444444444444444

The first five characters in the string after 5 \times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.

Sample Input 2

3
157

Sample Output 2

3

The initial string is 3. The string after 5 \times 10^{15} days consists only of 3.

Sample Input 3

299792458
9460730472580800

Sample Output 3

2



Sample input:
1214
4


Sample output:
2

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in map(int, s[:k]):
  if i != 1:
    print(i)
    break
else:
  print(1)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a = min(len(s),k)
z=1
for i in range(a):
	if s[i]=="1":
		pass
	else:
		z=s[i]
		break
print(z)

Submission status: Accepted

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

def check_one(sgn,arr):
    cnt = 0
    for i in range(sgn):
        if S[i] == '1':
            cnt += 1
    if cnt == sgn:
        return True

def first_num(arr):
    list = []
    for i in range(len(arr)):
        if arr[i] != '1':
            list.append(int(arr[i]))
    return list[0]
            

if len(S) >= K and check_one(K,S):
        print(1)
else:
    print(first_num(S))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

S = str(input())
K = I()

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

if p==-1:
    print(1)
elif p>=K:
    print(1)
else:
    print(val)

Submission status: Accepted

Solution code:
import re

s = input().split()[0]
k = int(input().split()[0])

m = re.search(r'[2-9]+', s)

if m:
    index = m.start()
    ans = m.group()[0] if index < k else '1'
else:
    ans = '1'

print(ans)

Submission status: Accepted

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

ans = 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s,k=open(0)
for i,c in enumerate(s):
  if c=="1":
    if i+1==int(k):break
  else:break
print(c)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    i = 0
    while i < len(S) and S[i] == "1":
        i += 1
    if K <= i:
        return "1"
    else:
        return S[i]

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

pos = 1
for c in S:
    num = int(c)
    if num == 1 and pos < K:
        pos += 1
        continue
    else:
        print(num)
        break

Submission status: Accepted

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

for i in range(K):
    if S[i] == "1" and K == i+1:
        ans = 1
        break
    elif S[i] != "1":
        ans = int(S[i])
        break

print(ans)

Submission status: Accepted

Solution code:
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    S = sys.stdin.readline().rstrip()
    K = int(sys.stdin.readline())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

if len(s)==1:
    print(s)
else:
    if s[0]!='1':
        print(s[0])
    elif set(s)=={'1'}:
        print(1)
    else:
        for i in range(len(s)):
            if s[i]!='1':
                a=i
                if k<=a:
                    print(1)
                else:
                    print(s[i])
                break

Submission status: Accepted

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

one = 0
while one<len(s) and s[one]=='1':
    one += 1

ans = '1'
if k > one:
    ans = s[one]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import re

S = input().rstrip()
K = int(input())

reg = re.search(r'[2-9]', S)
if reg:
    i = reg.start()
else:
    i = len(S) + 1


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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a = 1
for i in range(min(len(s),k)):
    if s[i] == "1":
        pass
    else:
        a = s[i]
        break
print(a)

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

Submission status: Accepted

Solution code:
def solve():
    s = input()
    k = int(input())
    head_ones = 0
    for c in s:
        if c != "1":
            break
        else:
            head_ones += 1

    return "1" if head_ones >= k else [c for c in s if c != "1"][0]


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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

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

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

Submission status: Accepted

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

isOne=True
for i in range(min(k, len(s))):
  if s[i]!="1":
    isOne=False
    ans=s[i]
    break
if isOne:
  print(1)
else:
  print(ans)

Submission status: Accepted

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

    cnt = 0
    for s in S:
        if s == '1':
            cnt += 1
            if K == cnt:
                print(1)
                exit()
        else:
            print(s)
            exit()



main()

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
ans="1"
l=len(s)

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a=1
for i in range(min(len(s),k)):
	if s[i] == '1':
		pass
	else:
		a = s[i]
		break
print(a)

Submission status: Accepted

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = list(inputs[0])
    K = int(inputs[1])

    if len(S) == 1:
        return int(S[0])

    for i, c in enumerate(S):
        if c == '1' and K == i + 1:
            return 1
        elif c != '1':
            return int(c)

    # count = 0
    # for i, c in enumerate(S):
    #     print(int(c) ** (49 * (10**14))
    #     # count += int(c) ** (49 * (10**14))
    #     # if count > K:
    #     #     return S[i-1]
    # return c


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Submission status: Accepted

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

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(1)
		break
	elif s[i]!="1":
		print(s[i])
		break

Submission status: Accepted

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

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

if check == 0:
    ans = 1
else:
    if tmp > K :
        ans = 1
    else:
        ans = S[tmp-1]

print(ans)

Submission status: Accepted

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

if S[0] == "1" and K <= n:
    print(1)
elif S[0] == "1" and K > 1:
    print(S[n])
elif S[0] != "1":
    print(S[0])

Submission status: Accepted

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

s = input().strip()
k = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(S: str, K: int):

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

    print(S[K-1])

    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 = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
k = getint() - 1

t = list(itertools.takewhile(lambda s: s == '1', s))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	s = input().strip()
	k = int(input().strip())
	ans = "1"
	for i in range(len(s)):
		if s[i] != '1' and i+1 <= k:
			ans = s[i]
			break
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

num1 = 0

for c in s:
    if c == "1":
        num1 += 1
    else:
        break

if num1 == len(s):
    nex = s[num1-1]
else:
    nex = s[num1]
if k <= num1:
    print(1)
else:
    print(nex)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

n = 5 * 10 ** 15
l = 0
ans = 0
for i in S:
  if (int(i) != 1):
    ans = int(i)
    break
  else:
    l += 1
if (l >= K):
  ans = 1

print(ans)

Submission status: Accepted

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

def func():
    if len(S) < K:
        for s in S:
            if s != 1:
                return s
    else:
        for i,s in enumerate(S):
            if s != 1:
                return s
            if i == K-1:
                return s

print(func())

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
while cnt<len(s) and s[cnt]=="1":
    cnt += 1

if cnt == 0:
    print(s[0])
elif cnt >= k:
    print(1)
else:
    print(s[cnt])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a = input()
d = int(input())
b = 0
c = ""
for i in range(len(a)):
    if a[i] == "1":
        b += 1
    else:
        c = a[i]
        break
print(1 if b >= d else c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(int(_) for _ in input())
    K = int(input())
    for i in range(len(S)):
        if S[i] == 1 and i+1 == K:
            print(1)
            return
        elif S[i] != 1:
            print(S[i])
            return
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if len(s) == 1:
    print(s)
elif len(set(s)) == 1:
    print(s[0])
else:
    t = s.replace('1','')
    if k < len(s) - len(t):
        print(1)
    else:
        print(t[0])

Submission status: Accepted

Solution code:
s=input();k=int(input())
if len(s)>=k:
	if s[:k]=="1"*k:
		print(1);exit()
print(s.replace("1","")[0])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
count_ones = 0
inf_n = 0
for c in S:
  n = int(c)
  if n == 1:
    count_ones += 1
  else:
    inf_n = n
    break
if K <= count_ones:
  print(1)
else:
  print(inf_n)

Submission status: Accepted

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

for i in s:
    if i == "1":
        k -= 1
        if k == 0:
            print(1)
            exit()
    else:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int,list(input())))
k = int(input())
n=len(s)
for i in range(n):
  if s[i]>1:
    tmp=s[i]
    break

if n>=k:
  if sum(s[0:k])==k:
    print(s[k-1])
  else:
    print(tmp)
else:
  print(tmp)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
count = 0
while True:
    if count >= len(s):
        break
    if s[count] == "1":
        count += 1
    else:
        break
if k > count:
  print(s[count])
else:
  print(1)

Submission status: Accepted

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

Submission status: Accepted

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

if all([c == '1' for c in S]):
    print(1)
    exit(0)

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

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

Submission status: Accepted

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

ind = -1

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

if ind == -1:
    print(1)
else:
    print(s[ind])

Submission status: Accepted

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

N = min(len(S), K)
for n in range(N):
    if S[n]!='1':
        print(int(S[n]))
        break
else:
    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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a-1)*(b-1))
    return

#B
def B():
    def est(n):
        res = 0
        for i in range(1, int(n ** 0.5) + 1):
            if not n % i:
                res += 2
        res -= float.is_integer(n ** 0.5)
        return res == 8
    n = II()
    ans = 0
    for i in range(1, n + 1, 2):
        ans += est(i)
    print(ans)
    return

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

#D
def D():
    return

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

Submission status: Accepted

Solution code:
S = str(input())

K = int(input())

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

Submission status: Accepted

Solution code:
s = input()
n = int(input())
 
count = 0
for i in s:
    count+=1
    if i != "1" or count == n:
        print(i)
        break
else:
    print(1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC105C
import sys

s = input()
k = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

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

Submission status: Accepted

Solution code:
import copy
import sys
import math

def main():
	n = int(input())
	k = int(input())
	s = str(n)
	if(k == 1):
		print(s[0])
		sys.exit()
	for i in s[:k]:
		if(i!='1'):
			print(i)
			sys.exit()
	print(1)


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Submission status: Accepted

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

Submission status: Accepted

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

def ones(s):
    ss = s[0]
    idx = 0
    while ss=="1" and idx+1 < len(s):
        idx += 1
        ss = s[idx]
    return idx

if s[0]!="1":
    print(s[0])
else:
    idx = ones(s)
    if idx>=k:
        print("1")
    else:
        print(s[idx])

Submission status: Accepted

Solution code:
s_list = list(input())
k = int(input())
for s in s_list:
  if int(s) != 1:
    print(s)
    break
  else:
    if k == 1:
      print(1)
      break
    else:
      k = k - 1

Submission status: Accepted

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

n = len(s)
su = 0
res = "0"
t = 0
for i in range(n):
    if s[i] == "1":
        t += 1
        if t == k:
            res = "1"
            break
    else:
        res = s[i]
        break
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
N = []
for s in S:
    N.append(int(s) ** 100)

for s, n in zip(S, N):
    K -= n
    if K <= 0:
        print(s)
        break

Submission status: Accepted

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

Submission status: Accepted

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

c1 = 0
ans = S[0]
for i, s in enumerate(S):
    if s != '1':
        ans = s
        break
    c1 = i+1

if c1 >= K:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

n = -1
for i, ki in enumerate(s):
  if ki!='1':
    n = i+1
    break
    
if n<0 or k<n:
  print(1)
else:
  print(s[n-1])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
i = 0
while True:
    if S[i] == '1':
        if K == 1:
            break
        else:
            K-=1
            i+=1
    else:
        break
print(S[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
List = []
ans = 1
num = 0
for i in range(len(S)):
    List.append(int(S[i]))
for j in range(len(S)):
    if List[j] != 1:
        ans = List[j]
        num = j+1
        break
if K < num:
    print(1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

res=''

if len(s)>=k:
	for i in range(k):
		if s[i]!='1':
			res=s[i]			
			break
		if i==k-1:
			res='1'
else:
	for i in range(len(s)):
		if s[i]!='1':
			res=s[i]
			break

print(res)

Submission status: Accepted

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

lst = [0]*100
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()
#print(lst)
j = 0
n = 0
while lst[j] == 1:
    n = j+1
    j += 1
#print('n =',n)
if K <= n:
    print(1)
else:
    print(lst[n])

Submission status: Accepted

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

ans = 1
count = 0

if len(S) == 1:
    ans = S[0]
else:
    for i in S:
        if i == "1":
            count += 1
        if not i == "1":
            if K > count:
                ans = i
                break
            else:
                ans = 1
print(ans)

Submission status: Accepted

Solution code:
# 2019/07/13

s=list(map(int,list(input())))
k=int(input())

if len(s)>=k and sum(s[:k-1])==k-1:
    ans=s[k-1]
else:
    for e in s:
        if e!=1:
            ans=e
            break

print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
ans = '1'

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

print(ans)

Submission status: Accepted

Solution code:
import re

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

if k < 100:
    oneLst = ["1"]*k
else:
    oneLst = ["1"]*100
oneStr = ''.join(oneLst)
if int(s) >= k and s[:k] == oneStr:
    print(1)
else: 
    res = re.search(r"[2-9]|0",s)
    print(res.group(0))

Submission status: Accepted

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

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else:
        if K<lst[0]+1:
            print('1')
        else:
            print(S[lst[0]])

Submission status: Accepted

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

idx = -1
for i, ss in enumerate(s):
    if ss != '1':
        idx = i
        break

ans = ''
if idx == -1:
    # 全て１のとき
    ans = '1'
else:
    if (idx + 1) <= K:
        ans = s[idx]
    else:
        ans = '1'
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)