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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
mojiretsu = list(input())

# いっこ入力
k =int(input())

ii=0

#print(len(mojiretsu))
for i in range(0,len(mojiretsu)):
    if mojiretsu[i] != '1':
        ii = i
        a = mojiretsu[i]
        break

# print(i)

if k <= ii:
    print(1)
else:
    print(a)

Submission status: Runtime Error

Solution code:
i = int(input())
K=int(input())
lst = []
while i > 0:
    lst.append(i%10)
    i //= 10 # 必須
lst.reverse()
j=0
while 1:
    if lst[j] == 1 and j == K:
        print(1)
        break
    if not lst[j] == 1:
        print(lst[j])
        break
    j+=1

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
for i,j in enumerate(S):
    if not j == "1":
        tmp = i+1
        break
if K < tmp:
    print("1")
else:
    print(j)

Submission status: Runtime Error

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

l=0

while s[l] == '1':
    l+=1

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
idx = 0
while idx < len(s) and s[idx] == '1':
    idx += 1
if k < idx:
    print(1)
else:
    print(s[idx])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

a = 0
while s[a] == '1':
    a += 1

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

Submission status: Runtime Error

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

i=0
while(s[i]=="1"):
    i +=1
print(s[i])

Submission status: Runtime Error

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

def test(x):
  return x % 2 == 1 and sum(x % y == 0 for y in range(1, x+1)) == 8

S = input()
K = read() - 1
i0 = next(i for i in range(len(S)) if S[i] != '1')
if K < i0:
  print(1)
else:
  print(S[i0])

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

for i, si in enumerate(s):
    if si != '1':
        ind = i
        res = si
        break
    if i == len(s):
        res = 'one'

if res == 'one':
    print(1)
elif ind >= k:
    print(1)
else:
    print(res)

Submission status: Runtime Error

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

head1num = 0
while S[head1num] == '1':
  head1num += 1

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

Submission status: Runtime Error

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

    if s[:k] == "1"*k:
        return 1
    else:
        return (s.replace("1", ""))[0]


print(abc106_c())

Submission status: Runtime Error

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

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

if k <= not1:
    print(1)
else:
    print(first_not1)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

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

k = 0
while S[k] == '1' and k < K:
    k += 1

if k == K:
    print('1')
else:
    print(S[k])

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] =  [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [long(input_raw[0])]
    count = 0;
    for s in S:
        if s != "1":
            break;
        count += 1
    if count >= K:
        print S[K]
    else:
        print S[count]

if __name__ == '__main__':
    main()