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
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    K = int(input())
    if len(S) > K and S[K-1] == '1':
        print('1')
        exit()
    for i in list(S):
        if i != '1':
            print(i)
            exit()
    print('1')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if s[:k].count('1') == len(s[:k]):
    print(1)
else:
    for c in s:
        if c != '1':
            print(c)
            exit()

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
    else:
        ans = int(s[i])
        break
if count >= k:
    ans = 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=input()
K=float(input())
lis=list(S)
ss=set(lis)

if len(ss)==1:
  print(S[0])
else:
  if K<=len(S):
    check_list=lis[:int(K)]
    check_set=set(check_list)
    if len(check_set)==1:
      print(check_list[0])
    else:
      for num in lis:
        if int(num)!=1:
          print(int(num))
          break            
  else:
    for num in lis:
      if int(num)!=1:
        print(int(num))
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

# 1の連続性を確認し終わった段階の数字を記録
cnt = 0

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

if cnt >= k:
    print(1)
else:
    print(num)

Submission status: Accepted

Solution code:

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

# 1の連続性を確認し終わった段階の数字を記録
cnt = 1

if len(s) == 1:
    print(s)
    exit()

for i in range(len(s)-1):
    if s[i] != '1':
        num = s[i]
        break
    if s[i] == s[i+1] == '1':
        cnt += 1

if cnt >= k:
    print(1)
else:
    print(num)

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = input().strip()
    n = int(input().strip()) - 1
    m=0
    for i in range(len(S)):
        if S[i] != '1':
            m = i
            break
    if n < m:
        print("1")
        return
    else:
        print(S[m])
        return


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

    result = 1

    for s in S[:K]:
        if int(s) > result:
            result = int(s)
            break

    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print('1')

Submission status: Accepted

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

count = 0
while count < len(S):
    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())
ans = "1"
for i in range(len(S)):
  if i >= K:
    break
  if S[i] != "1":
    ans = S[i]
    break

print(ans)

Submission status: Accepted

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

flag = True
for i in range(min(len(s),k)):
    if s[i] != 1:
        flag = False
    else:
        pass

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

Submission status: Accepted

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

flag = True
for i in range(min(len(s),k)):
    if s[i] != 1:
        flag = False
    else:
        pass

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

if k <= 100:
    a = 0
    for i in range(k):
        if s[i] != '1':
            break
        if i == str(k-1):
            print(1)
            sys.exit()
    print(s[i])
    
else:
    for i in range(100):
        if s[i] != '1':
            print(s[i])
            break

Submission status: Accepted

Solution code:
s=input()
k=int(input())
pos=-1
for i in range(len(s)):
    if(s[i]!='1'):
        pos=i;break;
if(pos==-1 or k<pos+1):
    print(1);exit()
print(s[pos])

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(min(len(s),k)):
    if s[i] != "1":
        print(s[i])
        exit(0)
print(1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
S = input()
K = int(input())
if len(S) == 1:
  print(S)
  sys.exit(0)
if K == 1:
  print(S[0])
  sys.exit(0) #
i = 0
while i<len(S):
  if S[i] == '1':
  	i += 1
  else:
    break
if i < len(S):
  keep = S[i]
else:
  keep = S[i-1]
if K <= i:
  print('1')
  sys.exit(0)
else:
  if S[0] != '1':
    print(S[0])
  else:
	  print(keep)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = '1'

if s.count('1') == len(s) or k == 1 and s[k-1] == '1':
    print(1)
else:
    for i in range(k):
        if s[i] != '1':
            ans = s[i]
            break
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

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

    count1 = 0
    for i in range(len(s)):
        num = int(s[i])
        if num == 1:
            count1 += 1
            if count1 == k:
                print(1)
                sys.exit()
        if num != 1:
            print(num)
            sys.exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])

K = int(input())

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

if K > 100:
    print(start)
elif K-1 >= loc:
    print(start)
else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

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

tmp_S = S[:K]
if tmp_S.count('1')==K:
    print(1)
    exit()
else:
    for i in range(len(S)):
        if S[i]!='1':
            print(S[i])
            exit()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

first = 0

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

print(1)

Submission status: Accepted

Solution code:
from sys import exit

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
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
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    S=list(map(int,list(input())))
    K=int(input())
    for n in S:
        if n==1:
            K-=1
            if K==0:
                print(1)
                exit()
        else:
            print(n)
            exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=input()
m=int(input())
x=list(x)

if len(x)<m:
	m=len(x)
t=1
for i in range(m):
	if x[i]!='1' and t==1:
		t=x[i]
t=int(t)
print(t)

Submission status: Accepted

Solution code:
S=input()
k=int(input())
for i in range(min(len(S),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(len(S)):
  if int(S[i]) == 1:
    continue
  else:
    if i+1 <= K:
      ans = S[i]
      break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
b=int(input())
if b<101:
  if a[:b]=='1'*b:print(1)
  else:
    k=0
    while a[k]=='1':k+=1
    print(a[k])
else:
  k=0
  while a[k]=='1':k+=1
  print(a[k])

Submission status: Accepted

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

len1s = 0
for i in range(len(s)):
    if s[i] == "1":
        len1s += 1
        continue
    else:
        res = s[i]
        break
else:
    res = "1"

if k <= len1s:
    ans = "1"
else:
    ans = res

print(ans)

Submission status: Accepted

Solution code:


def submit():
    s = str(input())
    k = int(input())

    for i, c in enumerate(s, start=1):
        if c != "1":
            if i > k:
                break
            else:
                print(c)
                return

    # 全て1 or kまで1 
    print("1")
            

if __name__ == "__main__":
    submit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
li=list(set([s[i] for i in range(len(s))]))
k=int(input())
c=0
for i in range(len(s)):
  if s[i] != "1":
    t = s[i]
    j=i
    c=1
    break
if c==0:
  print(1)
else:
  if j<=k-1:
    print(t)
  else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
k = int(input())
lengh = 0
ans = '1'
flag = True
for i in list(s):
    if i != '1':
        ans = i
        break
if k <= len(s):
    for i in list(s)[:k]:
        if i == '1': continue
        flag = False
        break
    if flag: ans = s[k-1]
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

s = input().rstrip()
m = int(input().rstrip())

ans = s[0]
if m > 1:
    for i in range(m):
        if s[i] == "1":
            continue
        else:
            ans = s[i]
            break

print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
f = True
c = 0
for i in s:
    if i=='1' and f: c+=1
    else: 
        f=False
        break
if c==0:
    print(s[0])
else:
    if c>=k: print(s[0])
    else: print(s[c])

Submission status: Accepted

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

    for ci, c in enumerate(s):
        if c != '1' and k >= ci + 1:
            print(c)
            exit()

    print('1')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
k = int(input())
if k <= 100:
    if set(s[:k]) == set('1'):
        print(1)
        exit()
for _ in s:
    if _ != '1':
        print(_)
        exit()

Submission status: Accepted

Solution code:
S = [int(n) for n in list(input())]
K = int(input())
c = 0
for i in range(len(S)):
	s = S[i]
	if s == 1:
		c += 1
	else:
		k = 0
		while c < K:
			c += k ** s
			k += 1
	if c >= K:
		print(s)
		break

Submission status: Accepted

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

Submission status: Accepted

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

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

if all(s[i]=="1" for i in range(min(len(s),k))):
    print(1)
else:
    while s[0]=="1":
        s = s[1:]
    print(s[0])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(1)

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    s = [int(i) for i in list(input())]
    k = int(input())
    if max(s[:k]) == 1:
        print(1)
    else:
        for i in s:
            if i > 1:
                print(i)
                return 0

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
S=input()
K=int(input())
ans=''
i=0
while True:
    ans=S[i]
    if(K==(i+1)):
        print(ans)
        sys.exit()
    elif(ans=='1'):
        i+=1
    else:
        print(ans)
        sys.exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(s)):
    if s[i]=='1':
        if i == n-1:
            print(1)
            break
    else:
        print(s[i])
        break

Submission status: Accepted

Solution code:
print(max("1",input()[:int(input())].replace("1","")[:1]))

Submission status: Accepted

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

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

if not1==-1:
        print(1)
elif k > not1:
        print(s[not1])
else:
        print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
K=int(input())
N=len(S)
flag=1
if K>100:
    for i in range(N):
        if not(S[i]=="1"):
            print(S[i])
            break
else:
    for i in range(K):
        if not(S[i]=="1"):
            print(S[i])
            flag=0
            break
    if flag==1:
        print("1")

Submission status: Accepted

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

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

print(S[i])

Submission status: Accepted

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    s = input()
    k = int(input())
    n = 0
    while n<=k-1:
        if not s[n]=='1':
            print(s[n])
            exit()
        else:
            n += 1
    print('1')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
s = list(input())
k = int(input())
n = min(k, len(s))
for i in range(n):
    if s[i]!="1":
        print(s[i])
        sys.exit()
    if i == n-1:
        print(1)

Submission status: Accepted

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

    for i,s in enumerate(S):
        s = int(s)
        if s != 1:
            print(s)
            return
        if i+1 == k:
            print(1)
            return
    print(1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
def calculate(S,K):
    normalStart = 1
    firstOneArr = []
    for s in S:
        if s != "1":
            normalStart = int(s)
            break
        else:
            firstOneArr.append(1)
    if K > len(firstOneArr):
        print(normalStart)
    else:
        print(1)
calculate(S,K)

Submission status: Accepted

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


if K < cnt:
    ans = S[0]
else:
    ans = S[cnt - 1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode().strip()
K = int(readline())
ans = 1
for i in range(K):
    if N[i] != '1':
        ans = N[i]
        break

print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode().strip()
K = int(readline())
cnt = 0
tmp = 0

for i in N:
    if i == '1':
        cnt += 1
        continue
    else:
        tmp = int(i)
        break
ans = N[tmp-1] if K <= cnt else tmp

print(ans)

Submission status: Accepted

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

if set(s[:k]) == set(['1']):
    print(1)
else:
    for x in s[:k+1]:
        if x != '1':
            print(x)
            break

Submission status: Accepted

Solution code:
s = input()

k = int(input())

ichi = 0
for i in s:
    if int(i) == 1:
        ichi = ichi +1
    else:
        break


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

Submission status: Accepted

Solution code:
import math

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

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
    
n=5000*10000**3

if len(ss)==0:
    print(1)
elif k<=0:
    print(1)
else:
    logk=math.log10(k)

    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(1)

Submission status: Accepted

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

if ind == len(s):
    print(1)
else:
    if K <= ind:
        print(1)
    else:
        print(s[ind])

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

if (S[0] == '1' and K - 1 < num):
    ans = 1
elif (S[0] == '1'):
    ans = S[num]
else:
    ans = S[0]

print(ans)

Submission status: Accepted

Solution code:
s=[int(i) for i in list(input())]
k=int(input())-1
n=len(s)
flag=False
for i in range(n):
  if s[i]==1:
    if k<=i:
      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
else:
  print(1)

Submission status: Accepted

Solution code:
import math
def main():
    s = input()
    n = int(input())
    for i, ss in enumerate(s):
        num = int(ss)
        if i < n:
            if num == 1:
                continue
            else:
                print(num)
                return
        else:
            print(1)
            return
    print(1)
    return
def powpow(a,n):
    x = 1
    i = 0
    while n > 0:

        if bin(n>>i & 1):
            x=x*a
        a*=a
        i+=1
        n=n>>1
    return x

if __name__=='__main__':
    main()

Submission status: Accepted

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

for n in range(K - 1):
    if N[n] != "1":
        print(N[n])
        exit()
print(N[K - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 2019
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
k=ii()

500000000000000
5*10^14

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

cnt=0
chk=True
ans=1
for i in range(len(s)):
    if chk and s[i]=="1":
        cnt+=1
    elif chk and s[i]!="1":
        chk=False
        ans=int(s[i])

    else:
        chk=False

if cnt >=k:
    print(1)
else:
    print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for s in S:
    if s != "1":
        print(s)
        exit()
    else:
        K -= 1
        if not K:
            print(1)
            exit()

Submission status: Accepted

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

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

cnt=0 #1の個数
i=0
while True:
    if s[i]!='1': break
    else:
        cnt+=1
        i+=1
        if i>len(s)-1: break
        
print(1 if k<=cnt else s[cnt])

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    S=list(input())
    K=int(input())
    S=[int(s) for s in S]
    for i in range(K):
        if S[i]!=1:
            print(S[i])
            break
        else:
            if i==K-1:
                print(1)

Submission status: Accepted

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