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: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
k = ni()
ans_idx = 0
for i in range(len(s)):
    if s[i] == "1":
        if i == len(s) - 1:
            ans_idx = 0
        continue
    else:
        ans_idx = i
        break
if ans_idx - 1 >= k:
    print("1")
else:
    print(s[ans_idx])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

is_first_1 = False
for i in S:
    if i == '1':
        if is_first_1 == False:
            is_first_1 == True
        if is_first_1 and i == K:
            print(1)
            exit()

    else:
        print(i)
        exit()

Submission status: Wrong Answer

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

for i, si in enumerate(s):
    if si > 1:
        break

if k <= i + 1:
    print(1)
else:
    print(si)

Submission status: Wrong Answer

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

if k == 1:
    print(s[0])
else:
    for si in s:
        if si > 1:
            print(si)
            break

Submission status: Wrong Answer

Solution code:
import sys


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

if s == "1" * len(s):
    print(1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc106/tasks/abc106_c
# C - To Infinity
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:
    print('None')
    ans = '1'

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for c in s:
  if c != '1':
    print(c)
    exit()
  else:
    continue
print(1)

Submission status: Wrong Answer

Solution code:
def solve():
    s = input()
    return "1" if set(s) == {"1"} else [c for c in s if c != "1"][0]


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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[1])
elif S[0] != "1":
    print(S[0])

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
S = input()
K =int(input())
if S[0]=="1" and K==1:
    print(1)
elif S[0]=="1" and K!=1:
    print(S[1])
elif S[0]!="1":
    print(S[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(s)

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

print(answer)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
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: Wrong Answer

Solution code:
s = list(map(int, input().split()))
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: Wrong Answer

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

print(answer)

Submission status: Wrong Answer

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

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

print(answer)

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = 5 * 10 ** 15
ans = S[0]
for i in S:
  if (int(i) != 1):
    ans = int(i)
    break
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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','')
    c = t[0]
    print(c)

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
if len(s) == 1:
    print(s)
else:
    if s[0] != 1:
        print(s[0])
    else:
        print(s[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
  if n > 2:
    inf_n = n
    break
if K <= count_ones:
  print(1)
else:
  print(inf_n)

Submission status: Wrong Answer

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

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

print(1)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = int(input())
 
for i in s:
    if i != "1":
        print(i)
        break

Submission status: Wrong Answer

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

for i in s:
    if i != "1":
        print(i)
        break
else:
    print(1)

Submission status: Wrong Answer

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-1]:
		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: Wrong Answer

Solution code:
import copy
import sys
import math

def main():
	n = int(input())
	k = int(input())
	s = str(n)
	for i in s[:k-1]:
		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: Wrong Answer

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: Wrong Answer

Solution code:
s = input()
n = int(input())
if s.count('1') == n:
    print('1')
else:
    for i in range(min(len(s),n)):
        if s[i] > '1':
            print(s[i])
            break

Submission status: Wrong Answer

Solution code:
s = input()
n = int(input())
if s.count('1') == n:
    print('1')
else:
    for i in range(len(s)):
        if s[i] > '1':
            print(s[i])
            break

Submission status: Wrong Answer

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

l = []
cnt = []
for i in s:
    if len(l) == 0:
        l.append(i)
        cnt.append(1)
    elif l[-1] == i:
        cnt[-1] += 1
    elif l[-1] != i:
        l.append(i)
        cnt.append(1)
#print(l,cnt)

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

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
c = 5*(10**15)

l = []
cnt = []
for i in s:
    if len(l) == 0:
        l.append(i)
        cnt.append(1)
    elif l[-1] == i:
        cnt[-1] += 1
    elif l[-1] != i:
        l.append(i)
        cnt.append(1)
#print(l,cnt)

n = len(cnt)
su = [0]*(n+1)
for i in range(1,n+1):
    if l[i-1] == "1":
        su[i] = su[i-1] + cnt[i-1]
    else:
        su[i] = su[i-1] + cnt[i-1]*c*int(l[i-1])
#print(su)

res = "0"
for i in range(1,n+1):
    if su[i-1] < k and k <= su[i]:
        res = l[i-1]
        break
print(res)

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
c = 5*(10**15)

l = []
cnt = []
for i in s:
    if len(l) == 0:
        l.append(i)
        cnt.append(1)
    elif l[-1] == i:
        cnt[-1] += 1
    elif l[-1] != i:
        l.append(i)
        cnt.append(1)
#print(l,cnt)

n = len(cnt)
su = [0]*(n+1)
for i in range(1,n+1):
    if l[i-1] == "1":
        su[i] = su[i-1] + cnt[i-1]
    else:
        su[i] = su[i-1] + cnt[i-1]*c*int(l[i-1])
#print(su)

res = "0"
for i in range(1,n+1):
    if su[i-1] <= k and k <= su[i]:
        res = l[i-1]
        break
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

  else:
    print(s[1])

else:
  print(s[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

elif set(S) == 1:
    print(S)

elif int(K) == 1:
    print(S[0])

elif S[0] == 1:
    print(S[1])
    
else:
    print(int(S[0]))

Submission status: Wrong Answer

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: Wrong Answer

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:
			res='1'
else:
	for i in range(len(s)):
		if s[i]!='1':
			res=s[i]
			break

print(res)

Submission status: Wrong Answer

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

res=''

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

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

print(res)

Submission status: Wrong Answer

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

lst = [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: Wrong Answer

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

ans = 1

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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]:
            print('1')
        else:
            print(S[lst[0]])

Submission status: Wrong Answer

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:
        print(S[lst[0]])

Submission status: Wrong Answer

Solution code:
n = input()
k = int(input())
if len(n) > 1:
  if k > 1:
    if n[0] is not '1':
      print(n[0])
    else:
      print(n[1])
  else:
    print(n[0])
else:
  print(n[0])

Submission status: Wrong Answer

Solution code:
n = input()
k = int(input())
if len(n) > 1:
  if k > 1:
    if n[0] is not '1':
      print(n[0])
    else:
      print(1)
  else:
    print(n[0])
else:
  print(n[0])

Submission status: Wrong Answer

Solution code:
S = input()
ans = "1"
for c in S:
    if c != "1":
        ans = c
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
ans = ""
for c in S:
    if c != "1":
        ans = c
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K == 1:
  print(S[0])
  exit()

for s in S:
  if int(s) != 1:
    print(s)
    break
else:
  print(1)

Submission status: Wrong Answer

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

for s in S:
  if int(s) != 1:
    print(s)
    break
else:
  print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
if S[0] == 1 and K > 1:
    print(S[1])
else:
    print(S[0])

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
if S[0] == 1 and K == 1:
    print(S[0])
else:
    print(S[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
i=0
while i<k:
  if s[i]!=1:
    x=s[i]
    break
  i+=1
if i==k:
  x=1
print(x)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
# print(S, K)
for s in S:
    if s != '1':
        print(s)
        exit()
print('1')

Submission status: Wrong Answer

Solution code:
S = list(input())
print(S)
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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = str(input())
k = int(input())
counter = 0
for i in range(k):
    if i != "1" and i <= k-1:
        print(i)
        counter += 1
        break
if counter == 0:
    print(1)

Submission status: Wrong Answer

Solution code:
s = str(input())
k = int(input())
counter = 0
for i in s:
    if i != "1":
        print(i)
        counter += 1
        break
if counter == 0:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(map(int,input()))
j = 1
for i in s:
	if i != 1:
		j = i
		break
	else:
		continue
print(j)

Submission status: Wrong Answer

Solution code:
s = list(map(int,input()))
j = 1
for i in s:
	if i != 1:
		j = i
		break
print(j)

Submission status: Wrong Answer

Solution code:
# 混乱する

s = input()
k = int(input())
if k == 1:
    print(s[0])
else:
    if s[0] == "1":
        for i in s:
            if i != "1":
                print(i)
                exit()
        print(1)
    else:
        print(s[0])

Submission status: Wrong Answer

Solution code:
# 混乱する

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

Submission status: Wrong Answer

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)
if cnt >= K:
    ans = 1
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans_idx = 0

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

Submission status: Wrong Answer

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

            
if s[0]!= '1':
    answer = s[0]
else:
    if k ==0 or len(s)==1:
        answer =s[0]
    else:
        if len(s)>=k:
            for i in range(k):
                if s[i]!='1':
                    sub = 1
                    count = min(i,count)
        if sub ==0:
            answer = '1'
        else:
            answer =s[count]

print(answer)

Submission status: Wrong Answer

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

            
if s[0]!= '1':
    answer = s[0]
else:
    if k ==0 or len(s)==1:
        answer =s[0]
    else:
        if len(s)>=k:
            for i in range(k):
                s[i]!='1'
                sub = 1
                count = min(i,count)
        if sub ==0:
            answer = '1'
        else:
            answer =s[count]

print(answer)

Submission status: Wrong Answer

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

            
if s[0]!= '1':
    answer = s[0]
else:
    if k ==0 or len(s)==1:
        answer =s[0]
    else:
        if len(s)>=k:
            for i in range(k):
                s[i]!='1'
                sub = 1
        if sub ==0:
            answer = '1'
        else:
            answer =s[1]

print(answer)

Submission status: Wrong Answer

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

            
if s[0]!= '1':
    answer = s[0]
    sub = 1
else:
    if k ==0 or len(s)==1:
        answer =s[0]
        sub = 1
    else:
        if len(s)>=k:
            for i in range(k):
                s[i]!='1'
                sub = 1
        else:
            answer =s[1]
            sub = 1

if sub ==0:
    answer = '1'
print(answer)

Submission status: Wrong Answer

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

            
if s[0]!= '1' and len(s)>1:
    answer = s[0]
    sub = 1
else:
    if k ==0 or len(s)==1:
        answer =s[0]
        sub = 1
    else:
        if len(s)>=k:
            for i in range(k):
                s[i]!='1'
                sub = 1
        else:
            answer =s[1]

if sub ==0:
    answer = '1'
print(answer)

Submission status: Wrong Answer

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

if len(s)>=k:
    for i in range(k):
        if s[i]=='1':
            answer = 1
elif s[0]!= '1' and len(s)>1:
    answer = s[0]
else:
    if k ==0 or len(s)==1:
        answer =s[0]
    else:
        answer =s[1]

print(answer)

Submission status: Wrong Answer

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


if s[0]!= '1' and len(s)>1:
    answer = s[0]
else:
    if k ==0 or len(s)==1:
        answer =s[0]
    else:
        answer =s[1]

print(answer)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
S=input()
K=int(input())
for k,s in zip(range(K),S):
  if not int(s)==1:
    print(s)
    break
  elif k==K and int(s)==1:
    print(1)
    break

Submission status: Wrong Answer

Solution code:
S=input()
K=int(input())
for i in S:
  if not int(i)==1:
    print(i)
    break

Submission status: Wrong Answer

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

    if (S[0] == "1"):
        return S[1]
 
    return S[0]

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

    print(calc(S, K))