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:
# -*- coding: utf-8 -*-
import logging
import time
import math


class Solver:
    def __init__(self):
        self.s = ''
        self.k = 0

    # 入力
    def input_value(self):
        # self.n = int(input())
        # self.A, self.B = map(int, input().split())
        # self.A = list(map(int, input().split()))
        # self.a, self.b, self.c = map(int, [input() for i in range(4)])
        # self.t = [None] * self.n
        self.s = input()
        self.k = int(input())

    # @staticmethod
    # def run(s, k):
    #     # count = [None] * len(s)
    #     sum = 0
    #     for i in range(len(s) + 1):
    #         # count[i] = int(s[i]) ** (5 * 10 ** 15)
    #         # sum += int(s[i]) ** (5 * 10 ** 15)
    #         sum += (5 * 10 ** 15) * math.log10(int(s[i]))
    #         if sum > math.log10(k):
    #             return s[i]
    #     return '0'

    @staticmethod
    def run(s, k):
        # count = [None] * len(s)
        i = 0
        while s[i] == '1':
            i += 1
            if i >= len(s) or i >= k:
                return '1'
        return s[i]

    @staticmethod
    def test():
        start_time = time.time()

        assert Solver.run('1214', 4) == '2', 'Error.'
        assert Solver.run('3', 157) == '3', 'Error.'
        assert Solver.run('299792458', 9460730472580800) == '2', 'Error.'
        assert Solver.run('123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789', 100000000000000000) == '2', 'Error.'
        assert Solver.run('11123', 2) == '1', 'Error.'
        assert Solver.run('11123', 3) == '1', 'Error.'
        assert Solver.run('11123', 4) == '2', 'Error.'
        assert Solver.run('11123', 5) == '2', 'Error.'

        elapsed_time = time.time() - start_time
        logging.debug('elapsed_time: {0}'.format(elapsed_time) + '[sec]')


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    solver = Solver()
    # Solver.test()

    solver.input_value()
    ans = solver.run(solver.s, solver.k)
    print(ans)

Submission status: Accepted

Solution code:
import math

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

n=0
for i in range(len(S)):
    if math.log10(int(S[i]))*5*(10**15)>=math.log10(K):
        break
    else:
        K-=int(S[i])**(5*(10**15))

print(S[i])

Submission status: Accepted

Solution code:
S = int(input())
K = int(input())
l = [int(x) for x in list(str(S))]
flag=0
flag2=0
i=0
j=0
ans = 0
if K<=len(l):
    while j<K and flag2 == 0:
        if l[j] == 1 or l[j]==0:
            ans = l[j]
            j = j + 1
        else:
            flag2 =1
            ans = l[j]
else:
    while flag ==0:
        if l[i] == 1 or l[i]==0:
            i = i + 1
        else:
            flag=1
            ans = l[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mrinfinit(a, b):
    bf = list(set(a))
    rr = a[:b]
    sf = list(set(rr))

    if len(bf) == 1 and bf[0] == '1':
        return a[0]
    elif len(sf) == 1 and sf[0] == '1':
        return a[0]
    elif len(a) > 1:
        if '1' in a:
            a = a.replace('1', '')
            return a[0]
        else:
            return a[0]
    else:
        return a[0]


if __name__ == '__main__':
    la = input()
    lb = int(input())
    print(mrinfinit(la, lb))

Submission status: Accepted

Solution code:
S = input()
K = input()
k =int(K)
flag = 0
for i in range(len(S)):
    if S[i] =="1":
        if i == k-1:
            break
        continue
    elif S[i] =="2":
        print("2")
        flag = 1
    elif S[i] =="3":
        print("3")
        flag = 1
    elif S[i] =="4":
        print("4")
        flag = 1
    elif S[i] =="5":
        print("5")
        flag = 1
    elif S[i] =="6":
        print("6")
        flag = 1
    elif S[i] =="7":
        print("7")
        flag = 1
    elif S[i] =="8":
        print("8")
        flag = 1
    elif S[i] =="9":
        print("9")
        flag = 1

    break
if flag == 0:
    print("1")

Submission status: Accepted

Solution code:
inp = [input() for _ in range(2)]
s = inp[0]
k = int(inp[1])
j = 0

for i in s:
  if i == "1":
    j += 1
  else:
    ans = int(i)
    break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S=input()
li=''.join(S)
S1=len(li)
m=[]

K=int(input())
ans=str(K)
k1=''.join(ans)
k2=len(k1)

for i in range(0,S1):
    if li[i]!='1' and i<K:
        print(li[i])
        sys.exit()

print('1')

Submission status: Accepted

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

cnt = 0
# 1の連続数
one_cnt = 0
for i in s:
    cnt += 1

    if i == "1":
        one_cnt += 1

    # 最後の数字までに1以外が含まれなかった場合
    if cnt == len(s):
        ans = 1

    # 1以外の数値が出現した時点でbreak
    if i != "1":
        ans = i
        break

# Kが1の連続カウント数以下の場合、答えは1となる。
if k <= one_cnt:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
n = input()
m = int(input())
j = 0
for i in n:
    j += 1
    if j == m:
        print(i)
        break
    elif i != "1":
        print(i)
        break

Submission status: Accepted

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

num = 1
one_cnt = 0
for i in s:
    if i != 1:
        num = i
        break
    else:
        one_cnt += 1
if (one_cnt >= K):
    print(1)
else:
    print(num)

Submission status: Accepted

Solution code:

S=[int(x) for x in list(input())]
K=int(input())
count=0
if len(S)==1:
    print(S[0])
else:
    for i, box in enumerate(S):
        if box==1:
            count+=1
            if count==K:
                print(1)
                break
        else:
            print(S[i])
            break

Submission status: Accepted

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

SL = list(S)
for i in range(0,101):
    if int(SL[i]) == 1:
        count1 += 1
    else:
        break
    if count1 == K:
        break

if count1 >= K:
    print(1)
else:
    if count1 >= 1:
        while "1" in SL:
            SL.remove("1")
    print(SL[0])

Submission status: Accepted

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

K = int(input())
cnt = 0

for i in range(len(S)):
	cnt += 1
	if(S[i]!=1 and K-1>i):
		ans = S[i]
		break

if(cnt==len(S) and K<=len(S)):
	print(S[K-1])
elif(cnt==len(S)):
	print(S[0])
else:
	print(ans)

Submission status: Accepted

Solution code:
input1 = raw_input().replace("\n", "")
input2 = int(raw_input().replace("\n", ""))

def count_ones(xs):
    count = 0
    for x in xs:
        if int(x) != 1:
            break
        else:
            count += 1
    return count

if int(input1[0]) > 1:
    print input1[0]
else:
    len_ones = count_ones(input1)
    if input2 <= len_ones:
        print 1
    else:
        print input1[len_ones]

Submission status: Accepted

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


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

    # 1桁目が、1以外のときは、1桁目を表示
    if s[0] != '1':
        print(s[0])
        return

    count_one = 0
    for c in s:
        if c == '1':
            count_one += 1
        else:
            break

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


main()

Submission status: Accepted

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

if '1' not in S:
  print(S[0])
  exit()


inf_num = list(filter(lambda x: x != '1', S[:K]))
if K <= len(S):
  if len(inf_num) == 0:
    print('1')
    exit()

print(inf_num[0])

Submission status: Accepted

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

for c in S:
    c = int(c)
    if c == 1:
        K -= 1
        if K <= 0:
            print(1)
            break
    else:
        print(c)
        break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a = 0
m = float('inf')
for i in s:
    if k <= int(i) ** m + a:
        print(i)
        break
    else:
        a += int(i) ** m

Submission status: Accepted

Solution code:
#入力
S = input()
K = int(input())
#文字数のカウント用
t = 0
index = 0
#5000兆(定数)
const = 5000000000000000
flag = False

for i in range(0,len(S)):
    #s_i^constを足す、途中でKを超えれば止める
    #1ならt+=1のみ
    if int(S[i]) == 1:
        t += 1
        if K < t:
            index = i
            flag = True
        if flag:
            break
    else:
        for j in range(1,const + 1):
            t2 = int(S[i]) ** j
            if K < t+t2:
                index = i
                flag =True
            if flag:
                break
   
print(S[index])

Submission status: Accepted

Solution code:
a=input()
k=int(input())
a=list(a)
#print(a)
d=0
for i in range(0,len(a)):
    if a[i]!='1':
        break
    d+=1
if a[0]=='1':
    if k<=d:
        print("1")
    else:
        for i in range(0,len(a)):
            if a[i]!='1':
                print(a[i])
                break
else:
    print(a[0])

Submission status: Accepted

Solution code:
import sys

str_s = input()
k = input()

int_s = int(str_s)
k = int(k)

gosentyo = 5000000000000000
count = 0

# print(2 ** gosentyo)


for s in str_s:
    now_count = 1

    if int(s) == 1:
        count += 1
        if count >= k:
            print(s)
            sys.exit()
    else:
        for i in range(gosentyo):
            # print(count,now_count)
            if (now_count + count >= k):
                print(s)
                sys.exit()
            now_count *= int(s)
        else:
            count += now_count

Submission status: Accepted

Solution code:
S=str(raw_input().strip("\n").strip())
K=int(raw_input())
N=len(S)
pos=0
for x in xrange(N):
    if(S[x]!='1'):
        pos=x
        break
if(pos>K-1): print("%c"%('1'))
else: print("%c"%S[pos])

Submission status: Accepted

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

Submission status: Accepted

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

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

S2 = ""
for i in range(len(S)):
    if S[i] == "1":
        S2 += "1"
    else:
        S2 += S[i] * 100
        break

if K <= 100:
    print(S2[K-1])
else:
    print(S2[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# your code goes here
S = str(input())
K = int(input())
#print(S, K)
count = 0
while(count < len(S) and S[count] == "1"):
	count += 1
#print(count)
if(K <= count):
	print("1")
else:
	print(S[count])

Submission status: Accepted

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

X = 0
for s in S:
    if s == "1":
        X += 1
    else:
        break

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

elif K <= X:
    print(1)

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

Submission status: Accepted

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

S = list(s)
answer = []

for i in range(len(S)):
    if S[i] == '1':
        answer.append(S[i])
    else:
        answer.append(S[i])
        break

if K <= len(answer):
    print(answer[K-1])
else:
    print(answer[-1])

Submission status: Accepted

Solution code:
# coding:utf-8
s=input()
k=int(input())
lists=list(s)
ans=1
for i in range(min(k,len(lists))):
    if not lists[i] == "1":
        ans=lists[i]
        break
print(ans)

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = raw_input()
K = input()

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

if cnt >= K:
    print 1
else:
    print c1

Submission status: Accepted

Solution code:
S, K = map(int, [input() for i in range(2)])
count = 0
a = 0

for i in str(S):
    if int(i) == 1:
        count += 1
        continue
    else:
        a = int(i)
        break

if count >= K:
    print(1)
else:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = raw_input().strip()
    k = int(raw_input().strip())
    for c in s:
        if k == 1:
            print c
            break
        if c == '1':
            k -= 1
        else:
            print c
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = '1'
count = 0
for s in S:
    if s == '2' or s == '3' or s == '4' or s == '5' or s == '6' or s == '7' or s == '8' or s == '9':
        ans = s
        break
    count += 1
    if count == K:
        break
    
print(ans)

Submission status: Accepted

Solution code:
S = input()
SS =list(S)
K = int(input())
ans = 1
for i in range(len(S)):
    if SS[i] != '1' and K>=i+1:
        print(SS[i])
        exit()
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
n = input()
k = int(input())
c = list(n)
d = deque(c)
ans=0
while len(d) > 0:
    a = d.popleft()
    i = int(a)
    if i==1:
        k = k-1
        if k==0:
            ans = 1
            break
    else:
        ans = i
        break


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=input()
K=int(input())
num=0
count=0
flag=0
for i in N:
  count+=1
  if int(i)!=1:
    num=int(i)
    flag=1
    break
if count>K or flag==0:
  print(1)
else:
  print(num)

Submission status: Accepted

Solution code:
ss=input()
k=int(input())
s=[int(i) for i in ss ]
#ls=len(s)
j=0
q=0
w=0
while q==0:
    if s[j]==1:
        w+=1
        if k<=w:
            print(1)
            q=1
        j+=1
    else:
        print(s[j])
        q=1

Submission status: Accepted

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

a=0
count=0
for i in s:
    if i=="1":
        count+=1
    else:
        a=i
        break
        
if k<=count:
    print(1)
else:
    print(int(a))

Submission status: Accepted

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

num1=1
ans = 0
for i in range(100):
	a =s//(10**(99-i))
	a -= (a//10)*10
	if a>1:
		ans = a
		break
	num1 +=a
	

if k < num1:
	ans = 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
for c in S:
    if (c == '1'):
        count += 1
    else:
        ans = c
        break

if (K <= count):
    print('1')
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
if K == 1:
	print(S[0])
	exit()
else:
	i = 0
	K -= 1
	while S[i] == "1" and K > 0:
		i += 1
		K -= 1
	print(S[i])

Submission status: Accepted

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


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

    for si in s:
        if si == '1':
            one_count += 1
        else:
            break

    if s[0] == '1':
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[one_count])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(map(int,list(input())))
k = int(input())
for item in s:
  if item == 1:
    k -= 1
  else:
    k -= 1000000000000000000
  if k <= 0:
    print(item)
    break

Submission status: Accepted

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

if K!=1 and len(S)!=1 and int(S[0])==1:
    num1 = 0
    for i in S:
        if int(i)==1:
            num1 +=1
        else:
            break
    if K<=num1:
        print(1)
    else:
        print(S[num1])
else:
    print(S[0])

Submission status: Accepted

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

for i,c in enumerate(s):
    if c != "1":
        print(c)
        exit()
    elif i+1 == k:
        print("1")
        exit()
print("1")

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
result = '1'
result = 1
for i,c in enumerate(s):
    if i == k - 1:
        result = c
        break

    if c == '1':
        pass
    else:
        result = c
        break

print(result)

Submission status: Accepted

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

if int(s[0]) == 1:
  one_count = 0
  i = 0
  while i < len(s) and int(s[i]) == 1:
    one_count += 1
    i += 1
  if k <= one_count:
    print(1)
  else:
    print(s[one_count])
else:
  print(s[0])

Submission status: Accepted

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

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

Submission status: Accepted

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

    if s[0] != '1':
        print(s[0])
        return

    cnt = 0
    for a in s:
        if a == '1':
            cnt += 1
        else:
            break

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

Submission status: Accepted

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

for i in S:
    if i == '1':
        K -= 1
        if K == 0:
            print(1)
            break
    else:
        print(i)
        break

Submission status: Accepted

Solution code:
import math
N = 5000000000000000
S = input()
K = math.log(int(input()))
for i in S:
  num = int(i)
  if num == 1:
    if num == int(math.exp(K)):
      print(num)
      break
    else:
      K = math.log(int(math.exp(K)-1))
      continue
  kk = N * math.log(num)
  if kk >= K:
    print(num)
    break
  else:
    K -= kk

Submission status: Accepted

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def count_first_1(s):
    count = 0
    first_letter = ''

    for letter in s:
        if letter == '1':
            count += 1
        else:
            first_letter = letter
            break

    return count, first_letter


if __name__ == "__main__":
    s = S()
    k = I()

    count, first_letter = count_first_1(s)

    if not first_letter:
        result = '1'

    elif count >= k:
        result = '1'

    else:
        result = first_letter

    print(result)

Submission status: Accepted

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

if s[0] != "1":
    print(int(s[0]))
else:
    count = 0
    i = 0
    if len(set(s)) == 1:
        print(1)
    else:
        while s[i] == "1":
            count += 1
            i += 1
        if k <= count:
            print(1)
        else:
            print(int(s[i]))

Submission status: Accepted

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

for i in range(K):
    if (int(S[i]) == 1):
        ans = int(S[i])
        continue
    if (int(S[i]) >= 2):
        ans = int(S[i])
    break

print(ans)

Submission status: Accepted

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


if S[0]!='1':
    print(S[0])
    sys.exit()

first_non1=1
count=0
find=0
for i in range (len(S)):
    if S[i]!='1' and find==0:
        first_non1=S[i]
        count=i
        find+=1
        
if int(K)<count+1:
    print(1)
else:
    print(int(first_non1))

Submission status: Accepted

Solution code:
import math
time = 5 * 10**15

num = list(input())
k = int(input())

chk = 0
count = 0
while chk == 0:
    if num[0] == '1':
        num.pop(0)
        count += 1
        if len(num)==0:
            break
    else:
        chk = 1

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

Submission status: Accepted

Solution code:
S=list(input())
K=int(input())
S0=[]
for i in S:
    if i=='1':
        S0.append(i)
    else:
        S0.append(i)
        break
if K>=len(S0):
    print(S0[-1])
else:
    print(S0[K-1])

Submission status: Accepted

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

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    nex=int(it)+int(1)
    print(s[it:nex])

Submission status: Accepted

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

if b!=3:
    print(S[K-1])

Submission status: Accepted

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

i = 0
while s[i] == 1 and k != 1:
    k -= 1
    i += 1
print(s[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for i in S:
    if i != '1':
        print(i)
        break
    K -= 1
    if K == 0:
        print(1)
        break

Submission status: Accepted

Solution code:
import math

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

n1 = 0
first_non1 = 0
for s in S:
    sint = int(s)
    if sint == 1:
        n1 += 1
    else:
        first_non1 = sint
        break


if K <= n1:
    print(1)
else:
    print(first_non1)

Submission status: Accepted

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

one = 0
two = '1'

for c in s:
    if c == '1':
        one += 1
    else:
        two = c
        break

if k <= one:
    print(1)
else:
    print(two)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(int, list(str(input()))))
k = int(input())
i = 0
if s.count(1) == len(s):
  print(1)
else:
  while s[i] == 1:
    i += 1
  if k <= i:
    print(1)
  else:
    print(s[i])

Submission status: Accepted

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

if len(S)==1:
    print(S[0])
    quit()

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

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

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

Submission status: Accepted

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

cc = 0
for i in S:
  if i != "1":
    break
  else:
    cc += 1
if cc < K:
  print(i)
else:
  print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [int(x) for x in list(str(input()))]
K = int(input())
j=1
i=-1

while( j==1 and i<len(S)-1 ):
  i = i+1
  j = S[i]

if(K<=i):  print(1)
else:  print(j)

Submission status: Accepted

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

S = input()
K = input()
K_len = len(K)
K = int(K)

Cn = []
# GOSENCHO = 5000000000000000


for str in S:
    si = int(str)
    if si == 1:
        Cn.append(1)
    else:
        Cn.append(10000000000000000000)

# print(Cn)
tmp = 0
for i,Ci in enumerate(Cn):
    tmp += Ci
    if K <= tmp:
        print(S[i])
        break

Submission status: Accepted

Solution code:
S = list(input())
N, = list(map(int,input().split()))

ans = 1
num_1 = 0

for i in range(len(S)):
    if  not S[i] == '1':
        ans = int(S[i])
        break
    else:
        num_1 += 1

if  len(S) == 1:
    ans = int(S[0])
if  num_1 >= N:
    ans = 1
        
print(ans)

Submission status: Accepted

Solution code:
import sys
s=input()
k=int(input())
if k<105:
    if s[:k]=="1"*k:
        print("1")
        sys.exit(0)
i=0
while True:
    if s[i]!="1":
        print(s[i])
        break
    i+=1

Submission status: Accepted

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

index = 1

ans = 1

for i, c in enumerate(s, 1):
    if c != '1':
        ans = c
        break
    elif k == str(i):
        break


print(ans)

Submission status: Accepted

Solution code:
S=input()
K=int(input())
S1=""
if K==1:
	print(int(S[0:1]))
elif K>100:
	print(S.replace("1","")[0:1])
else:
	for i in range(K):
		S1=S1+"1"
	if S[0:K]==S1:
		print(1)
	else:
		print(S.replace("1","")[0:1])

Submission status: Accepted

Solution code:
from sys import stdin, stdout

input = lambda: stdin.readline().rstrip()
write = stdout.write

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

    if K == 1:
        print(S[0])
    else:
        for s in S:
            if s == '1':
                K -= 1
            else:
                print(s)
                break
            if not K:
                print(s)
                break

main()

Submission status: Accepted

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

i=0
for c in s:
    if c!="1":
        res=c
        #print(i,res)
        break
    i+=1

if k>i:
    print(res)
else:
    print(1)

Submission status: Accepted

Solution code:
s = list(input())
s = [int(i) for i in s]
k = int(input())

for i in s:
    num = i
    if i == 1:
        k -= 1
        if k == 0:
            break
    else:
        break

print(num)

Submission status: Accepted

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

if k==1:
  print(s[0])
elif k>1:
  while c<k-1 and s[c]=="1":
    c+=1

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

Submission status: Accepted

Solution code:
from fractions import gcd
from sys import stdin
import math 
S = str(input())
K = int(input())
ans = 1

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
k = input()
nlen = 0
i = 0
if s[i] != "1":
    print(s[i])
else:
    while s[i] == "1":
        if nlen == (int(k)-1):
            break
        i += 1
        nlen += 1
    print(s[i])

Submission status: Accepted

Solution code:
line = input()
flag = True

for i in range(int(input())):
  if not(line[i]== '1'):
    print(line[i])
    flag = False
    break

if flag:
  print('1')

Submission status: Accepted

Solution code:
import math
S = input()
K = int(input())
# 5000兆
chou = 5*(10**15)

for c in S:
  # 倍率
  mag = int(c)
  if mag == 1:
    if K == 1:
      print(1)
      quit()
    else:
      K -= 1
      continue
  if chou >= math.log(K,mag):
    print(c)
    quit()
  # これはたぶんいらない
  else:
    K -= mag**chou
    print(K)

Submission status: Accepted

Solution code:

N = list(input())
L = int(input())

count = 0

for n in N:
    if n == "1":
        count+=1
    else:
        break

if count >= L:
    print(1)
else:
    print(N[count])

Submission status: Accepted

Solution code:
A=list(input())
B=int(input())
count=0
for i in A:
    if int(i)==1:
        pass
        count+=1
        if count==B:
            print(1)
            exit()
    else:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 20:38:47 2018
ABC106C
@author: maezawa
"""

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

if s[0]=='1':
    ans = 1
    cnt = 0
    for c in s:
        if c == '1':
            cnt += 1
        else:
            ans = c
            break
    if k <= cnt:
        print('1')
    else:
        print(ans)
else:
    print(s[0])

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
s = list(s)
count = 0
for i in s:
    if i != '1':
        break
    count += 1
if count >= k:
    print(1)
else:
    print(s[count])

Submission status: Accepted

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

flg = False

m = k
if len(s) < k:
    m = len(s)

for i in range(m):
    if s[i] != '1':
        print(s[i])
        flg = True
        break

if flg == False:
    print("1")

Submission status: Accepted

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


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

if one >= n:
    print(1)
else:
    print(ret)