Let's write all the positive integer numbers one after another from $$$1$$$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...Your task is to print the $$$k$$$-th digit of this sequence.

The first and only line contains integer $$$k$$$ ($$$1 \le k \le 10000$$$) — the position to process ($$$1$$$-based index).

Print the $$$k$$$-th digit of the resulting infinite sequence.

n = int(input())
for i in range(1,10001):
    i = str(i)
    if(len(i)>=n):
        for k in range(len(i)):
            n-=1
            if(n == 0):
                print(i[k])
    else:
        n-=len(i)

n = int(input())
i = 0
s = 0
while True:
	temp = (i+1)*9*(10**i)
	if s + temp <= n:
		s += temp
		i += 1
	else:
		break
tc = n - s

nd = tc//(i+1) - 1
tc -= (nd+1)*(i+1)
f = 10**i + nd
if tc != 0:
	print(str(10**i+nd+1)[tc-1])
else:
	print(str(10**i+nd)[-1])

def whereis(k):
    n = 1
    while k > 0:
        k -= 9*10**(n-1)*n
        n+=1
    else:
        n-= 1
        return n

def kthdigit(k):
    a = whereis(k)
    sequence = ''
    sum = 0
    for b in range(1, a):
        sum += 9*10**(b-1)*b
    i = k-sum
    divider = (i-1)/a
    remainder = (i-1)%a
    number = divider + 10**(a-1)
    string = ''
    for huh in range (number, number+1):
        string += str(huh)

    return string[remainder]
we = input()
print kthdigit(we)

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

for i in range(10000):
    s += str(i)
    if len(s) > k:
        print(s[k])
        break

def get1(n):
    res = 0
    st = 1
    while st <= n:
        res += len(str(st))
        st += 1
    return res

def get(n):
    if n == 0:
        return 0

    L = len(str(n))
    res = 0
    prev = 1
    for i in range(1, L):
        res += i * ((10**i) - prev)
        prev = (10**i)

    res += (n - 10**(L - 1) + 1) * L

    return res

def solve(n):
    start = 1
    end = 10**18
    it = 70
    while it:
        it -= 1
        mid = (start + end) / 2
        if get(mid) >= n:
            end = mid
        else:
            start = mid

    for i in range(mid - 5, mid + 5):
        if i >= 1:
            cur = str(i)
            s = ''
            for j in cur:
                s += j
                if get(i - 1) + len(s) == n:
                    return j
    return mid

n = input()
X = solve(n)
print X

k = int(input())
a = []
for i in range(5000):
	for j in range(len(str(i))):
		a.append(str(i)[j])
a = list(a)
print(a[k])

k = int(input())
s = ""
for i in range(1,10000):
    s+=str(i)
print(s[k-1])

a=''
n=int(input())
for i in range(1,2778):
    a+=str(i)
print(a[n-1])

def generate(n, x):
    a = 10 ** (n - 1)
    a += x
    return a

def solve(k):
    k -= 1
    n = 1
    while k - n * 9 * 10 ** (n - 1) >= 0:
        k -= n * 9 * 10 ** (n - 1)
        n += 1
    a = generate(n, k / n)
    return str(a)[k % n]

# print solve([100] * 11)
n = input()
print solve(n)

n=int(input())
ar=map(str,range(1,10001))
s=''
d=s.join(ar)
print(d[n-1])

n = int(input())
s = ''
i = 0
while len(s) <= n:
    s += str(i)
    i += 1
print(s[n])

import math
k = int(input())

def cnt_digit_order(X):
    res = 0
    if X == 0:
        return 0
    for i in range(1, X+1):
        res += i*(9*pow(10, i-1))
    return res

L = -1
leftcnt = 0
for length in range(1, 100):
    if cnt_digit_order(length - 1) < k <= cnt_digit_order(length):
        L = length
        leftcnt = k - cnt_digit_order(length - 1)
        break

#L = digits/length
M = str(math.ceil(leftcnt/L) + (10**(L-1) - 1))
leftcnt -= 1
leftcnt %= L
print(M[leftcnt])

k = int(input())
a = ""
for i in range(1, 5005) :
	a += str(i)
print(a[k-1])

k = int(input())
n = 1
up_bnd = 9
while(k > up_bnd):
    n += 1
    up_bnd += (9*n)*(10**(n-1))
low_bnd = 0
lb_val = 0
for i in range(1, n):
    low_bnd += (9*i)*(10**(i-1))
    lb_val = (lb_val*10)+9
num = int((k-low_bnd)/n) + lb_val
rm = (k-low_bnd) % n
if(rm != 0):
    num += 1
ans = 0
if(rm == 0):
    ans = num % 10
else:
    for i in range(n-rm+1):
        j = (num % 10)
        num = int(num/10)
        ans = j
print(int(ans))

l=[]
k=int(input())
for i in xrange(10**6):
    l.append(i)
s="".join(str(e) for e in l)
print s[k]

def get_kth_digit(i):
    if i < 10:
        return i

    batch = 9
    count = 9
    width = 1

    while i >  10 * batch * (width + 1) + count:
        batch *= 10
        width += 1
        count += batch * width

    k = i - count - 1
    num = 10 ** width + k// (width + 1)
    return str(num)[k % (width + 1)]

def main():
    i = int(input())

    print(get_kth_digit(i))

if __name__ == '__main__':
    main()

n=int(input())
s=''
for i in range(n+1):
    s=s+str(i)
print(s[n])

l=''
k=int(input())
index=0
counter=1
while True:
    for i in str(counter):
        if index<=k-1:
          l+=i
          index+=1
    counter+=1
    if index>k-1:
          break

if 1<=k <=10000:
     print(l[k-1])

#------------------------------what is this I don't know....just makes my mess faster--------------------------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#----------------------------------Real game starts here--------------------------------------
'''

___________________THIS IS AESTROIX CODE________________________
                       KARMANYA GUPTA

'''

for t in range(1):
	string = ''
	for i in range(1,10002):
		string += str(i)
	n = int(input())
	print(string[n-1])

l = []
n = []
sum = 0
multiply = 9
for i in range(1,12):
    s = '9' * i
    n.append(int(s))
    sum+=i*multiply
    multiply *= 10
    l.append(sum)
k = int(input())
if(k<9):
    print(k)
else:
    t = 0
    for i in range(len(l)):
        if(k < l[i]):
            t=i
            break
    temp = k-l[t-1]
    offset = temp%(t+1)
    value = temp//(t+1)
    number = n[t-1]+value
    if(offset == 0):
        print(number%10)
    else:
        number += 1
        offset -= 1
        print(str(number)[offset])

z = int(input())
string = ""
for i in range(1,z+2):
    string += str(i)
print(string[z-1])

k = int(input())

nc = [0 for i in range(14)]

for i in range(1, 14):
    nc[i] += nc[i - 1] + 9 * (10 ** (i - 1)) * i

for i in range(13):
    if nc[i] < k <= nc[i + 1]:
        cif = i + 1

if cif == 1:
    print(k)
    quit()

c = k - nc[cif - 1]

if c % cif == 0:
    nnr = c // cif
    ncif = cif
else:
    nnr = 1 + c // cif
    ncif = c % cif

number = nnr + 10 ** (cif - 1) - 1

while cif != ncif:
    number //= 10
    cif -= 1

print(number % 10)

k = int(input())
s = ''
i = 1

while(i<=k):
    s += str(i)
    i+=1

print(s[k-1])

def lint(n):    #to find length of an integer
    h = int(n)
    i= 0
    while(h>0):
          h= int(h/10)
          i=i+1
    len =i
    return len

k =int(input())
list = [1]
n=1
y=1
for y in range (1,k):
        n = n+1;
        p= lint(n)
        for i in range(p,0,-1):
                e= 10**(i-1)
                x = int(n/e)
                z= x%10
                list.append(z)

        y = y+p
print(list[k-1])

"""
Strategy: Split sequence into subsequences
according to number of digits. Then find corresponding
number and digit in that number.
"""

# Standard input.
k=int(input())

# Initilize sequence
num_digits=1
num_numbers=9

k-=1
while k>num_digits*num_numbers:
    # Move sequence starting point.
    k -= num_numbers*num_digits
    num_digits += 1
    num_numbers *= 10

# Generate number.
number = 10**(num_digits - 1) + k // num_digits
# Find index in that number
index = k % num_digits
answer = str(number)[index]
print(answer)

a = ''
for k in range(1, 10000):
    a = a + str(k)
    if len(a) >= 10000:
        break
s = int(input())
print(a[s-1])

k = int(input())
i = 1
s = ''
while len(s)<k:
    s+=str(i)
    i+=1
print(s[k-1])

import sys

if __name__ == "__main__":
    numstring = ""
    for k in range(1,10001):
        numstring += str(k)
    print(numstring[int(input())-1])

s='0'
for i in range(1,10000):
    s+=str(i)
print(s[int(input())])

# your code goes here

n = int(input())
num=""
for i in range(1,100000):
	num+=str(i)
print(num[n-1])

n=int(input())
st=""
le=0
for i in range(1,100000+1):
	st+=str(i)
	le+=len(str(i))
	if le>=n:
		break
j=le-n
print(st[-j-1])

k = int(input())
s = ''
for i in range(1,10000):
	s += str(i)
print(s[k-1])

k = int(input())

if k <= 9:
	print(k)

else:
	s = 9
	n = 1

	while s < k:
		n += 1
		prev_s = s
		s += (10**n - 10**(n-1)) * n

	digit_pos = k - (prev_s + 1)
	number = 10**(n-1) + digit_pos // n

	if digit_pos / n != digit_pos // n:
		digit_pos = digit_pos - (digit_pos // n) * n

	else:
		digit_pos = 0

	print(str(number)[digit_pos])

k = int(input())
c = 0
for i in range(1,10000):
    s = str(i)
    c = c + len(s)
    if c >= k:
        break
    else:
        continue

b = str(i)
if c == k:
    print(b[len(b)-1])
else:
    print(b[len(b)-(c-k)-1])

k = int(input())
s = ""
i = 0
while len(s) <= k:
    s += str(i)
    i += 1
print(s[k])

#Bhargey Mehta (Junior)
#DA-IICT, Gandhinagar
import sys, math, queue, bisect
#sys.stdin = open('input.txt', 'r')
MOD = 998244353
sys.setrecursionlimit(1000000)

n = int(input())
if n < 10:
    print(n)
    exit()
d = 1
while n > 9*d*pow(10, d-1):
    n -= 9*d*pow(10, d-1)
    d += 1
x = pow(10, d-1) + (n-1)//d
p = n % d
x = str(x).zfill(d)
print(x[p-1])

import bisect

b = []
a = []
b.append(0)

for i in range(1, 15):
	b.append(9 * i * (10 ** (i - 1)))

a.append(b[0])
for i in range(1, 15):
	a.append(a[i - 1] + b[i])

k = int(input())

th = bisect.bisect_left(a, k)
th -= 1;
k = k - a[th];
start = 10 ** th;
now = th + 1;
rem = k % now;
iss = k / now;
end = start + (k / now);
temp = str(end - 1);
s = "";
s += temp[now - 1] + str(end) + str(end + 1);

print(s[0 + rem])

import os
k = int(input())
string = ""
i=0
while len(string)<k:
	i=i+1
	string=string+str(i)
print(string[k-1])

bl=""
for i in range(1,12345):
    bl+=str(i)
n=int(input())
print(bl[n-1])

k = int(raw_input())
s = ""
for i in range(k):
	s += str(i+1)
print(s[k-1])

k = int(input())
s = ""
now = 1
while len(s) < k:
    s += str(now)
    now += 1
print(s[k-1])

k=int(input())
string_1=''
i=1;
while(len(string_1)<k):
    string_1=string_1+str(i)
    i=i+1

print(string_1[k-1])

digit=1
x=int(input())
start_range=1
end_range=9
nine=9
total=0
while(x>end_range):
    start_range=end_range+1
    digit+=1
    end_range+=(digit*nine*pow(10,digit-1))
    total=total+start_range

start=pow(10,digit-1)
number=int((x-start_range)/digit)
index=int((x-start_range)%digit)
start=start+number
string=str(start)
print(string[index])

k = int(input())
count = 1
number = 1
result = 0
number1 = 1
while True:
    if number == 1:
        if result + 9 < k:
            result += 9
            number = 20
            number1 = 10
        else:
            break
    elif number == 20:
        if result + 180 < k:
            result += 180
            number += 10
            number1 = 100
        else:
            break
    else:
        if result + 9 * number * 10**count < k:
            result += 9 * number * 10**count
            number += 10
            count += 1
            number1 *= 10
        else:
            break

while True:
    if count == 0:
        break
    if result + number * 10**count < k:
        result += number * 10**count
        number1 += 100 * 10**(count - 1)
    else:
        count -= 1

while True:
    if number == 1:
        break
    if result + number < k:
        result += number
        number1 += 10
    else:
        break

while True:
    if result + len(str(number1)) >= k:
        print(str(number1)[k - result - 1])
        break
    else:
        number1 += 1
        result += len(str(number1))

s = ""
k = int(input())
for i in range(1,10000):
    s+=str(i)
print(s[k-1])

k = int(input())
prev=0
nextt=0
NumofDigits=0
#i = 0
#while(summ<(2^12)):
while(True):
    prev = nextt
    nextt = nextt+(9*(10**(NumofDigits-1))*NumofDigits)
    if(k>= prev and k<=nextt):
        break
    NumofDigits=NumofDigits+1
if(NumofDigits==1):
    print(k)
else:
    result = (10**(NumofDigits-1))+int((k-(prev+1))/NumofDigits)
    i=0
    while(True):
        if (k-int(prev+1))%NumofDigits == i:
            break
        i=i+1
    result = str(result)
    print(result[i])

k = int(input())
a = ""
for x in range(1, k + 1):
	a += str(x)
print(a[k- 1])

def count(start, k):
    s = "_"
    while len(s) <= k:
        s += str(start)
        start += 1
    return s[k]

print(count(1, int(input())))

n = input()
if len(n) == 1:
    print(n)
    exit(0)
else:
    li = list(range(1, int(n)+1))
    s = ''
    for i in li:
        s += str(i)
    print(s[int(n)-1])

import sys
import math
import bisect

def main():
    val = 0
    A = []
    for i in range(1, 10000 + 1):
        s = str(i)
        A.append(s)
        val += len(s)
        if val >= 10000:
            break
    s = ''.join(list(str(a) for a in A))
    n = int(input())
    print(s[n-1])

if __name__ == "__main__":
    main()

k = int(input())
prev=0
next=0
NumofDigits=0
#i = 0
#while(sum<(2^12)):
while(True):
    prev = next
    next = next+(9*(10**(NumofDigits-1))*NumofDigits)
    if(k>= prev and k<=next):
        break
    NumofDigits=NumofDigits+1
if(NumofDigits==1):
    print(k)
else:
    result = (10**(NumofDigits-1))+int((k-(prev+1))/NumofDigits)
    i=0
    while(True):
        if (k-int(prev+1))%NumofDigits == i:
            break
        i=i+1
    result = str(result)
    print(result[i])

num=int(input())
null=''
for i in range(num+1):
    null+=str(i)
print(null[num])

def size_of_group(i):
    return long(9 * 10**(i - 1)) * i

def find_group(k, i = 1):
    diff = long(k - (size_of_group(i)))
    if diff <= 0:
        return k, i
    return find_group(diff, i + 1)

def get_number(k, g):
    return str(long(10**(g - 1)) + k / g)[k % g]

def get_sequence_number(num):
    """https://codeforces.com/problemset/problem/1177/B"""
    k_prim, g_prim = find_group(num)
    return get_number(k_prim - 1, g_prim)

# run program
if __name__ == "__main__":
    print(get_sequence_number(long(input())))

mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n=ii()
s=''
for i in range(1,5001):
    s+=str(i)
print(s[n-1])

k = int(input())
c = 0
for i in range(1,10000):
    s = str(i)
    c = c + len(s)
    if c >= k:
        break
    else:
        continue

b = str(i)
if c == k:
    print(b[len(b)-1])
else:
    print(b[len(b)-(c-k)-1])

from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def solve():
    n=inp()
    s=''
    for i in range(2800):
        s+=str(i)
    print(s[n])

for _ in range(1):
    solve()

import sys
k=int(input())
if type(k)!=int or k<=0 or k>pow(10,12) :
        print("wrong input. try again")
        sys.exit()
lim_init=lim=decimal=9
c=0
while True:
        c+=1
        if k<=lim:
                diff=lim-k #189-21
                pos=diff%c
                diff=int(diff/c) #168/2=84
                diff=decimal-diff #99-84
                print(''.join(list(reversed(str(diff))))[pos])
                break
        else:
                decimal = int(str(lim_init)*(c+1))
                lim+=int(str(lim_init)+'0'*c)*(c+1)

def ans(n):
    s=""
    i=1
    while(len(s)<n):
        s+=str(i)
        i+=1
    return(int(s[n-1]))
print(ans(int(input())))

k = int(input())
s = ""
for i in range(10000):
    s = s + str(i + 1)
print(s[k - 1])

import sys,math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int,sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=" "):
	return sys.stdin.readline().strip().split(delim)

###### Author : Samir Vyas #######
###### Write Code Below    #######
k = read_int()

base_digit_number = 1; expo = 0

while k >= base_digit_number:
	base_digit_number += 9*(expo+1)*(10**expo)
	expo += 1

base_digit_number -= 9*(expo)*(10**(expo-1))

ans_number = (k - base_digit_number)//expo + 10**(expo-1)

ans_digit = str(ans_number)[(k - base_digit_number)%expo]

print(ans_digit)

s = ""
for i in range(10000):
    s += str(i)
n = int(input())
print(s[n])

n=int(input())
s=0; pred=0
for i in range(1,20):
    m=9*pow(10,i-1)*i
    s+=m
    if n<=s:
        nd=pow(10,i-1)
        sme=n-pred
        num=sme//i
        ost=sme%i
        if ost==0:
            dig=nd+num-1
        else:
            dig=nd+num
        d=i
        rez=[]
        ddig=dig
        while d>0:
            o=ddig%10
            a=ddig//10
            rez.append(o)
            d-=1
            ddig=a
        break
    pred=s
print(str(rez[-ost]))

s=""
for i in range(1,3000):
    s=s+str(i)
#print(len(s))

k=int(input())
print(s[k-1])

k = int(input())

s = ""
for i in range(1,10000):
    s = s + str(i)

print(s[k-1])

bl=""
for i in range(1,12345):
    bl+=str(i)
n=int(input())
print(bl[n-1])

import sys
n=int(input())
ind=0
dig=0
for i in range(1,12):
    dig+=i*10**(i-1)*9
    #print(dig)
    if dig>n:
        ind=i-1
        rt=dig-i*10**(i-1)*9
        break
n-=rt
no=10**ind
#print(n)
if n==0:
    print(9)
    sys.exit()
u=n
n-=(n//(ind+1))*(ind+1)
no+=max(0,(u//(ind+1))-1)
#print(n)
if n==0:
    print(str(no)[-1])
else:
    no+=1
while(n>0):
    if n<=ind+1:
        e=str(no)
        print(e[n-1])
    n-=ind+1
    no+=1

n = int(input())
s = ""
for i in range(1, 10001):
  s+=str(i)
print(s[n-1])

def f(x): #including x
	dig, cnt = 1, 9
	ans = 0
	while dig != len(str(x)):
		ans += dig * cnt
		dig += 1
		cnt *= 10
	ans += (x - (cnt // 9) + 1) * dig
	return ans
k = int(input())
l, r = 1, 1000000000000
if k == 1:
    print(1)
    exit(0)
while l < r:
	mid = (l + r + 1) >> 1
	if f(mid) < k:
		l = mid
	else:
		r = mid - 1
k -= f(l)
l += 1
print(str(l)[k - 1])

n = int(input())
step = 9
count = 0
digit = 1
while (count + (digit * step) < n):
    count += (digit * step)
    step *= 10
    digit += 1
i = n - count
k = int((i+(digit-1)) / digit)
num = (10 ** (digit-1)) + (k-1)
j = digit - ((i + digit-1) % digit) - 1
while j > 0:
    num = int(num/10)
    j -= 1
print(num%10)

#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
n = int(input())-1
x, y = 1, 9
while n > x * y: n,x,y = n-x*y,x+1,y*10
a = str(10 ** (x - 1) + n // x)[n%x]
print(a)

while (True):
    k=int(input('donner k'))
    if (k>=1) or (k<=10000):
        break
ch=''
for i in range (1,k+1) :
    ch+=str(i)
print(ch)
print(ch[k-1])

import math

def countDigit(n):
	return math.floor(math.log(n, 10)+1)

n=int(input())
count=countDigit(n)
if count==1:
	print(n)
else:
	low=1
	high=9
	sum=[]
	sum.append(9)
	for i in range(1,16):
		low=low*10
		high=high*10+9
		sum.append((high-low+1)*2+sum[i-1])
		if n<sum[i]:
			digit=i
			break
	x=n-sum[digit-1]
	q=x/(digit+1)
	r=x%(digit+1)
	low=math.pow(10,digit)
	low=low+q-1
	#print(low)
	if r==0:
		print(int(low%10))
	else:
		n=low+1
		stringnum=str(n)
		print(int(stringnum[r-1]))

def size_of_group(i):
    if i == 1:
        return 10
    else:
        return long(9 * 10**(i-1))

def find_group(k, i = 1):
    diff = long(k - size_of_group(i))
    if diff <= 0:
        return k, i
    return find_group(diff, i + 1)

def get_number(k, g):
    return str(long(size_of_group(g - 1) + long(k / g)))[k % g]

def get_sequence_number(num):
    """https://codeforces.com/problemset/problem/1177/B"""
    k_prim, g_prim = find_group(num)
    return get_number(k_prim, g_prim)

# run program
if __name__ == "__main__":
    n = get_sequence_number(long(input()))
    print(n)

mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n=ii()
s=''
for i in range(1,1001):
    s+=str(i)
print(s[n])

n=int(input())
x=1
while n>(10**len(str(x))*9):
    n-=10**len(str(x))*9

    x*=10
while n>len(str(x)):
    n-=len(str(x))
    x+=1
for i in range(len(str(x))):
    if n!=0:
        s=str(x)[i]
        n-=1

print(s)

import math
k=int(input())
s=''
if k>=10000:
    k=k//int(math.log(k,10))
#print(k)
for i in range(1,k+1):
    s+=str(i)
print(s[k-1])

bl=""
for i in range(1,20000):
    bl+=str(i)
n=int(input())
if n>20000:
    print(1)
else:
    print(bl[n-1])

n=int(input())
st=""
for i in range(1,n+1):
    st+=str(i)
print(st)
print(st[n-1])

''' CODED WITH LOVE BY SATYAM KUMAR '''

from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys

sys.setrecursionlimit(10 ** 6)  # max depth of recursion
threading.stack_size(2 ** 27)  # new thread will get stack of such size
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
        self.lista = [[_] for _ in range(n)]

    def find(self, a):
        to_update = []
        while a != self.parent[a]:
            to_update.append(a)
            a = self.parent[a]
        for b in to_update:
            self.parent[b] = a
        return self.parent[a]

    def merge(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        if self.size[a] < self.size[b]:
            a, b = b, a
        self.num_sets -= 1
        self.parent[b] = a
        self.size[a] += self.size[b]
        self.lista[a] += self.lista[b]

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def prime_factors(n):  # n**0.5 complex
    factors = dict()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        while n % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1
            n = n // i
    if n > 2:
        factors[n] = 1
    return (factors)

def all_factors(n):
    return set(reduce(list.__add__,
                      ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
    if n < 2: return 1
    return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(
        fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
    if (p <= n):
        return 0
    res = (p - 1)
    for i in range(n + 1, p):
        res = (res * cached_fn(InverseEuler, i, p)) % p
    return res

def binary(n, digits=20):
    b = bin(n)[2:]
    b = '0' * (digits - len(b)) + b
    return b

def is_prime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True

def generate_primes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 1
    return prime

factorial_modP = []

def warm_up_fac(MOD):
    global factorial_modP, fac_warm_up
    if fac_warm_up: return
    factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
    for i in range(2, fac_warm_up_size):
        factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD
    fac_warm_up = True

def InverseEuler(n, MOD):
    return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
    global fac_warm_up, factorial_modP
    if not fac_warm_up:
        warm_up_fac(MOD)
        fac_warm_up = True
    return (factorial_modP[n] * (
            (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def display_2D_list(li):
    for i in li:
        print(i)

def prefix_sum(li):
    sm = 0
    res = []
    for i in li:
        sm += i
        res.append(sm)
    return res

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))

memory = dict()

def clear_cache():
    global memory
    memory = dict()

def cached_fn(fn, *args):
    global memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result

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

def binary_search(i, li):
    fn = lambda x: li[x] - x // i
    x = -1
    b = len(li)
    while b >= 1:
        while b + x < len(li) and fn(b + x) > 0:  # Change this condition 2 to whatever you like
            x += b
        b = b // 2
    return x

# -------------------------------------------------------------- MAIN PROGRAM

TestCases = False
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = True  # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3

def main():
    global x
    k = get_int()
    y, z = 0, 0
    for x in range(13):
        y += 9*(10**x)*(x+1)
        if y > k:
            break
        z += 9*(10**x)
    y = k - (y - 9*(10**x)*(x+1))
    x = x+1
    #print(y,x)
    no = z + (y-1)//x + 1
    dig = (y-1) % x
    print(str(no)[dig])
# --------------------------------------------------------------------- END=

if TestCases:
    for i in range(get_int()):
        main()
else:
    main() if not optimise_for_recursion else threading.Thread(target=main).start()

k=int(input())
a=""
for i in range(k):
    a=a+str(i+1)
print(a[k-1])
print(a)

def whereis(k):
    n = 1
    while k > 0:
        k -= 9*10**(n-1)*n
        n+=1
    else:
        n-= 1
        return n

def kthdigit(k):
    a = whereis(k)
    sequence = ''
    sum = 0
    for b in range(1, a):
        sum += 9*10**(b-1)*b

    for x in range(10**(a-1), 10**(a)):
        sequence += str(x)
    return sequence[k-sum-1]

def ans(n):
    s=""
    i=1
    while(len(s)<n):
        s+=str(i)
        i+=1
    return(int(s[n-1]))

def ans(n):
    s=""
    i=1
    while(len(s)<n):
        s+=str(i)
        i+=1
    return(s[n-1])

#digits sequence(Hard Edition)

n = int(input())

check = True
t=0
tnext=9
sm1=0
count=1
i=2
j=10
res = 0
while(check):

    if(n<=tnext):
        res=n-t
        check = False

    else:
        sm1 = sm1+t
        count = count+1

        if(t!=0):
            t=t*i*j
        else:
            t=9
        tnext = tnext * (i+1)*(j*10)
        i=i+1
        j=j*10

num1 = int(res/count)
num2 = res%count

print(count , t ,tnext , sm1)

des = pow(10,count-1)
despac = des + num1

print(despac)

if(num2 == 0):
    despac = str(despac -1)
    print(despac[-1])

else :
    despac = str(despac)
    print(despac[num2-1])

bl=""
for i in range(1,20000):
    bl+=str(i)
n=int(input())
if n>20000:
    if int(n)==100000:
        print(2)
    else:
        print(1)
else:
    print(bl[n-1])

digit=1
x=int(input())
start_range=1
end_range=9
nine=9
total=0
while(x>end_range):
    start_range=end_range+1
    digit+=1
    end_range=nine*start_range
    total=total+start_range
total+=(digit*start_range)
string=''
j=start_range

for i in range(x):
    string+=str(j)
    j+=1
print(string[x-start_range])

n = int(input())
counter = 0
cur_number = 0
cur_array = list()
while counter < n:
    cur_number += 1
    cur = cur_number
    result = 0
    cur_array = list()
    while cur > 0:
        cur_array.append(cur % 10)
        cur //= 10
    cur_array.reverse()
    for i in cur_array:
        result = i
        print(result)
        counter += 1
        if counter == n:
            break
print(result)

num = ""
count = 1
k = int(input())
while len(num) <= k:
    num += str(count)
    count += 1
print(num)
print(num[k-1])

s = ''
for i in range(1, 3000):
	s +=str(i)
print(len(s))
k = int(input())
print(s[k-1])

def f(n):
    n-=1
    kakn = 9
    chisl = 1
    while kakn < n:
        kakn+=((9*10**chisl)*(chisl+1))
        chisl+=1
        if n-kakn == 1:
            return 0
        elif n+1==kakn:
            return 9
    t=kakn-((9*10**(chisl-1)*chisl))
    n-=t
    p=n//chisl
    u = n%chisl
    o = str(t+p+1)
    return o[u]
n = int(input())
print(f(n))

def fun(x):
    i = 1
    temp = 9
    while(temp < x):
        i += 1
        temp += i*(10 ** (i - 1))*9
    y =  x - (temp - i*(10**(i-1))*9) - 1
    q = y / i
    r = y % i
    dgs = [int(d) for d in str(q)]
    while(len(dgs) != i):
        dgs.insert(0,0)
    if (r == 0):
        return dgs[r] + 1
    else:
        return dgs[r]

# i = int(input())
# print fun(i)

# @author

import sys

class ADigitsSequenceEasyEdition:
    def solve(self):
        k = int(input())
        p = 1
        c = 0
        while c + p * (10 ** p) < k:
            c += p * 10 ** p
            p += 1
        k -= (c - 1)
        bef = (10 ** (p - 1) if p > 1 else 0) + (k - 1) // p
        i = (k - 1) % p
        print(str(bef)[(k - 1) % p])

solver = ADigitsSequenceEasyEdition()
input = sys.stdin.readline

solver.solve()

from math import log
n = int(input())
r = int(log(n,10))
k = n-pow(10,r)+1
num = pow(10,r)-1
t = k//(r+1)
num = num + t
if k%(r+1) == 0:
	print((num)%10)
else:
	num = num + 1
	m = str(num)
	print(m[k%(r+1)-1])

from math import log
k=int(input())
r=k
l=1
t=int(log(10))
while 1:
	m=(l+r)//2
	x=int(log(m)/t)
	d=((1-10**(x+1))//9) + (m+1)*(x+1)
	if 0<=(k-d)<=13:
		break
	elif d>k:
		r=m-1
	else:
		l=m+1
if d==k:
	print(str(m)[-1])
	exit()
st=""

v=k-d
m+=1
for i in range(13):
	st+=str(m)
	m+=1
print(st[v-1])

# Digits Sequence 1177A
natural_num = ""
for i in range(1, 1001):
	natural_num += str(i)

list_each_digit = []
list_each_digit.append(0)
for letter in natural_num:
	list_each_digit.append(letter)

print(list_each_digit)

input_index = int(input())

print(int(list_each_digit[input_index]))

k=int(input(''))
ch=''
for i in range (1, k + 1):
    if (len(ch)<k):
        ch+=str(i)
print(ch)
ch=ch[:k+1]
print(ch[k-1])

k=int(input(''))
ch=''
for i in range (1, k + 1):
    while (len(ch)<k):
        ch+=str(i)
print(ch[k-1])

l = []
for i in range(10000):
  l.append(i)
list(''.join(map(str, l)))

a = int(input())
print(l[a])

k=int(input())
a=""
for i in range(k):
    a=a+str(i+1)
print(a[k-1])
print(a)

def decimal2Str(a : int):
    x = list()
    while a > 0:
        x = [str(a % 10)] + x
        a = int(a/10)
    return x
k = int(input())
index,adddigit = 1, 1
ans = []
tmp = k
while tmp >= adddigit:
    ans = ans + decimal2Str(index)
    index+=1
    tmp -= adddigit
    if index >= (10 ** adddigit):
        adddigit += 1
print(ans[-1])

k = int(input())
if k <= 9:
    print(k)
else:
    length = len(str(k))
    s = ""
    num = 0
    for i in range(length - 1):
        s = s + "1"
    #print(s)
    previous_value = 9 * int(s)
    for i in range(length - 1):
        num += (9*(10**i))*(i + 1)

    try_value = k - num
    #print(try_value)
    #print(previous_value)
    if try_value % length == 0:
        div_value = try_value // length
        temp_string = str(previous_value + div_value)
        print(temp_string[len(temp_string) - 1])
    else:
        div_value = (try_value // length) + 1
        temp_string = str(previous_value + div_value)
        differ = (div_value * length) - try_value
        print(temp_string[len(temp_string) - differ - 1])

from math import ceil
n=int(input())
if n<=9:
    print(n)
else:
    d=2
    ov=9
    while n>d*9*(10**(d-1))+ov:
        ov=d*9*(10**(d-1))+ov
        d+=1
        v=ceil((n-ov)/d)+int('9'*(d-1))
        print(str(v)[(n-ov-1)%d])

k = int(input())

mul = 1
count=0
d = 1

while k>mul*9*d:
    k-=mul*9*d
    count+=mul*9*d
    d+=1
    mul*=10

x = k%d
y = k//d
y+=mul

if x==0:
    print((y-1)%10)
else:
    print((y)//pow(10,d-x))

k=int(input(''))
ch=''
for i in range (1, k + 1):
    if (len(ch)<k):
        ch+=str(i)
print(ch)
print(ch[k-1])

c=[*range(1,int(input())+1)];b="";d=c[-1]
while c and len(b)<c[-1]:
	b=b+str(c.pop(0))
	print(b)
print(int(b[-1])) if len(b) <= 9 else print(int(b[d]))

k = int(input())
if k <= 9:
    print(k)
else:
    length = len(str(k))
    s = ""
    num = 0

    for i in range(length - 2):
        num += (9*(10**i))*(i + 1)
        temp = num + (9*(10**(i + 1)))*(i + 2)
        if temp > k:
            length = i + 2
            break

    for i in range(length - 1):
        s = s + "1"
    #print(s)

    previous_value = 9 * int(s)
    try_value = k - num
    #print(try_value)
    #print(previous_value)
    #print(length)
    if try_value % length == 0:
        div_value = try_value // length
        temp_string = str(previous_value + div_value)
        print(temp_string[len(temp_string) - 1])
    else:
        div_value = (try_value // length) + 1
        temp_string = str(previous_value + div_value)
        differ = (div_value * length) - try_value
        print(temp_string[len(temp_string) - differ - 1])

import os
k = int(input())
string = ""
i=0
while len(string)<k:
	i=i+1
	string=string+str(i)
print(string[-1])

k = int(input())
x = []
i=0
flag = True

while flag==True:
    x.append(9*(10**i))
    i = i+1
    if sum(x) >= k : flag = False

p = len(x)

base = sum(x) - x[p-1]
r = k - base
d = -((-r)//p)
dd = r%p
if dd==0: dd=p

number = str(base + d)
digit = number[dd-1]

# print(number)
print(digit)

k=int(input())
a=[]
for i in range(0,12):
    s=9*pow(10,i)*(i+1)
    if k<=s:
        break
    else:
        k-=s
pos=i+1
num=(pow(10,pos-1)+(k//pos)-1)
if k%pos==0:
    print(str(num+1)[-1])
else:
    print(str(num+1)[(k%pos)-1])

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print fast
pt = lambda x: sys.stdout.write(str(x)+'\n')

#--------------------------------WhiteHat010--------------------------------------#
n = get_int()
end = 0
digit = 0

while True:
    digit += 1
    a = 10**(digit-1)
    b = int('9'*digit)
    start = end+1
    end = b*digit
    if n <= end:
        break

term = str( a + ( (n-start+1)//digit - 1) )
#print(term)
#print('digit: ',digit)
rem = (n-start+1)%digit
#print(rem-1)
print(term[rem-1])

k=int(input())
s=''
for i in range(k):
    s+=str(i)
print(s[k-1])

k=int(input())

s=""
for i in range(1,10000):
	s=s+str(i)
if k>len(s):
	print("out")
else:
	print(s[k-1])

digit = int(input())

if int(digit) <= 9:
    print(digit)
    exit()

start_range = 1
end_range = 9

power = 1
digit_count = 2
while not (start_range <= digit and digit <= end_range):
    start_range = end_range + 1
    end_range = 9 * 10**power * digit_count + start_range - 1
    power += 1
    digit_count += 1

offset_number = (digit - start_range) // (digit_count - 1)
#print(f"{digit} - {start_range} mod {digit_count-1} = {offset_number}")
number = str(10**(power - 1) + offset_number)
#print(f"10^ {power - 1} + {offset_number} = {number}")
offset_digit = (digit - start_range) % (digit_count - 1)
#print(f"{digit} - {start_range} mod {digit_count - 1 } = {offset_digit}")
#print(f"{number} {number[-offset_digit]}")
print(f"{number[-offset_digit]}")

t=int(input())
s=""
for x in range(1,10001):
                   s=s+str(x)
print(s[t-1])
print(len(s))

def generate(n, x):
    a = 10 ** (n - 1)
    a += x
    return a

def solve(k):
    k -= 1
    if k <= 9:
        return str(k + 1)
    n = 1
    while k - n * 9 * 10 ** (n - 1) >= 0:
        k -= n * 9 * 10 ** (n - 1)
        n += 1
    a = generate(n, k / n)
    return str(a)[k % n]

# print solve([100] * 11)
n = input()
print solve(n)

def sequence(n):
    s = ''
    for i in range(10000):
        s += str(i)
    return s[n - 1]

print(sequence(int(input())))

def f(n):
    kakn = 9
    chisl = 1
    while kakn < n:
        kakn+=((9*10**chisl)*(chisl+1))
        chisl+=1
        if n-kakn == 2:
            return 0
    t=10**(chisl-1)
    n-=t
    p=n//chisl
    u = n%chisl
    o = str(t+p)
    return o[u]
n = int(input())
print(f(n))

k = int(input())
l=[]
for i in range(10000):
    l.extend(str(i))
print(len(l))

#Bhargey Mehta (Junior)
#DA-IICT, Gandhinagar
import sys, math, queue, bisect
#sys.stdin = open('input.txt', 'r')
MOD = 998244353
sys.setrecursionlimit(1000000)

n = int(input())
if n < 10:
    print(n)
    exit()
n += 1
d = 1
while n > 9*pow(10, d-1):
    n -= 9*pow(10, d-1)
    d += 1
x = pow(10, d-1) + n//d - 1
print(str(x)[n%d])

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print fast
pt = lambda x: sys.stdout.write(str(x)+'\n')

#--------------------------------WhiteHat010--------------------------------------#
n = get_int()
end = 0
digit = 0

while True:
    digit += 1
    a = 10**(digit-1)
    b = int('9'*digit)
    start = end+1
    end = b*digit
    if n <= end:
        break

if (n-start+1)%digit != 0:
    x = 1
else:
    x = 0
term = str( a + ( (n-start+1)//digit + x -1) )
#print(n-start+1)
#print('Term: ',term)
rem = (n-start+1)%digit
#print(rem-1)
print(term[rem-1])

digit=1
x=int(input())
start_range=1
end_range=9
nine=9
total=0
while(x>end_range):
    start_range=end_range+1
    digit+=1
    end_range+=digit*nine*start_range
    total=total+start_range
total+=(digit*start_range)
index=end_range-x
minus=int(index/2)
index%=2
last_number=pow(10,digit)-1
last_number-=minus
string=str(last_number)
print(string[len(string)-index-1])

n = int(input())
def exp_(i):
	return (9*pow(10,i)*i-(10**i)+1)//9
i = 1
while True:
	v = exp_(i)
	if v >= n:
		break
	i = i + 1
if n == v:
	print("9")
else:
	n = n - exp_(i-1)
	num = 10**(i-1) - 1
	num = num + n//(i)
	r = n%(i)
	if r > 0:
		num = num + 1
		f = str(num)
		print(f[r-1])

num = ""
count = 1
k = int(input())
while len(num) <= k:
    num += str(count)
    count += 1
print(num)
print(num[k-1])

k = int(input())
count = 1
number = 1
result = 0
number1 = 1
while True:
    if number == 1:
        if result + 9 < k:
            result += 9
            number = 20
            number1 = 10
        else:
            break
    elif number == 20:
        if result + 180 < k:
            result += 180
            number += 10
            number1 = 100
        else:
            break
    else:
        if result + 10 * number * 9**count < k:
            result += 10 * number * 9**count
            number += 10
            count += 1
            number1 *= 10
        else:
            break

while True:
    if count == 0:
        break
    if result + 10 * number * 9**(count - 1) < k:
        result += 10 * number * 9 ** (count - 1)
        number1 += 100 * 10**(count - 1)
    else:
        count -= 1

while True:
    if number == 1:
        break
    if result + number < k:
        result += number
        number1 += 10
    else:
        break

while True:
    if result + len(str(number1)) >= k:
        print(str(number1)[k - result - 1])
        break
    else:
        number1 += 1
        result += len(str(number1))

N = int(input())
beg = 0
end = 9
i = 0  # в скольки значных числах мы находимся - 1

while N > end:
    i += 1
    beg, end = end, end + (i + 1) * 9 * 10**i

n = N - beg - 1  # это N относительно начала чисел с длинной i, начиная с 0
lvl = i - n % (i + 1)  # номер симвала, начиная от конца числа
period = (i + 1) * 10**lvl  # период смены числа

res = n//period
if lvl == i:
    res += 1
print(res)

#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
a=[0,9]
for i in range (1,11):
    d=(i+1)*(9*10**i)
    a.append(a[-1]+d)
#print(a)
k=int(input())
c=-1
for i in range (12):
    if k<a[i]:
        k-=a[i-1]
        m=k%(i)
        #print(k,m,a[i])
        k//=i
        if i>1:
            k+=9*10**(i-2)
        #print(k)
        if m==0:
            c=int(str(k)[-1])
        else:
            k+=1
            c=int(str(k)[m-1])
        break
print(c)

k = int(input())
if (k < 10):
    print(k)
c=0
n=k
while (n > 0):
    c+=1
    sub = 10 ** c - 1
    n = (k - sub*c) / (c+1) + sub
    if (n < c ** 10):
        if (int(n) == n):
            print(int(n%(10**c)))
            break
        else:
            print(int((int(n)+1)/(10**c)))
            break

k = int(input())
ar = []
ith = 0
for i in range(1, k+1):
	for i in str(i):
		ar.append(i)
		ith+=1
	if ith==k:
		break
print(ar[-1])

def ans(n):
    s=""
    i=1
    while(len(s)<n):
        s+=str(i)
        i+=1
    return(s[n-1])

s = ''
for i in range(1, 3000):
	s +=str(i)
print(len(s))
k = int(input())
print(s[k-1])


Chouti was doing a competitive programming competition. However, after having all the problems accepted, he got bored and decided to invent some small games.He came up with the following game. The player has a positive integer $$$n$$$. Initially the value of $$$n$$$ equals to $$$v$$$ and the player is able to do the following operation as many times as the player want (possibly zero): choose a positive integer $$$x$$$ that $$$x<n$$$ and $$$x$$$ is not a divisor of $$$n$$$, then subtract $$$x$$$ from $$$n$$$. The goal of the player is to minimize the value of $$$n$$$ in the end.Soon, Chouti found the game trivial. Can you also beat the game?

The input contains only one integer in the first line: $$$v$$$ ($$$1 \le v \le 10^9$$$), the initial value of $$$n$$$.

Output a single integer, the minimum value of $$$n$$$ the player can get.

NoteIn the first example, the player can choose $$$x=3$$$ in the first turn, then $$$n$$$ becomes $$$5$$$. He can then choose $$$x=4$$$ in the second turn to get $$$n=1$$$ as the result. There are other ways to get this minimum. However, for example, he cannot choose $$$x=2$$$ in the first turn because $$$2$$$ is a divisor of $$$8$$$.In the second example, since $$$n=1$$$ initially, the player can do nothing.

from sys import stdin
n = int(stdin.readline())
if n==2:
    print 2
else:
    print 1

n = int(input())

x = n-1

if x!=0 and n%x!=0:
	print(n-x)
else:
	print(n)

n = int(input())
if n == 2:
    print(2)
else:
    print(1)

if int(input()) != 2:
    print(1)
else:
    print(2)

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output4.out",'w')
n=int(input())
if n!=2:
	print(1)
else:
	print(2)

a=int(input())

if a!=2:
    print(1)
else:
    print(2)

n = int(input())

if n == 2:
	print(2)
else:
	print(1)

N = int(raw_input())
if N==2:
    print 2
else:
    print 1

x=int(input())
if x!=2:
    print(1)
else:
    print(2)

def main():
    n=input()
    if n==2:
        print 2
    else:
        print 1

main()

x = int(input())

if x == 2: print(x)
else: print(1)

n=int(input())

if n==2: print(2)
else: print(1)

# -*- coding: utf-8 -*-
import heapq, math, random, re, string, sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from decimal import Decimal, getcontext
from fractions import gcd, Fraction
from itertools import combinations, permutations, product
from math import ceil, exp, log, sqrt
from Queue import Queue, PriorityQueue

getcontext().prec = 100
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7
INF = float('+inf')
'''
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    sys.stdin = io.BytesIO(sys.stdin.read())
    raw_input = lambda: sys.stdin.readline().rstrip()
'''
pr = lambda args: sys.stdout.write(' '.join(map(str, args)) + '\n')
epr = lambda args: sys.stderr.write(' '.join(map(str, args)) + '\n')
die = lambda args: pr(args) ^ exit(0)

n = input()
#a = [input()for _ in xrange(n)]
#n, m = map(int, raw_input().split())
#a = [map(int,raw_input().split())for _ in xrange(n)]
#s = raw_input()
#a = [raw_input() for _ in xrange(n)]

if n > 2:
	print 1
else:
	print n

inp = int(input())
if inp == 2:
    print(2)
else:
    print(1)

if input() == '2':
 print('2')
else:
 print('1')

n = int(input())
if n==2:
	print(2)
else:print(1)

n = int(input(""))
if n == 2:
    print(2)
else:
    print(1)

n = input()
if n ==2:
    print 2
else:
    print 1

import os
import sys
from collections import deque
import pdb
import heapq
from heapq import *
from pprint import pprint
from bisect import *
from math import *
sys.setrecursionlimit(999999999)
if(os.getcwd() == 'C:\\Users\\User\\Desktop\\python\\Prog'):
    pdb = pdb.Pdb(stdin=sys.stdin, stdout=sys.stdout)
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def rI():
    return [int(i) for i in input().split()]

n = rI()[0]
if(n <= 2):
    print(n)
else:
    print(1)

x = int(input())
if x != 2:
    print("1")
else:
    print("2")

n = int(input())
if n == 2:
    print("2")
else:
    print(1)

__author__ = 'Obriel Muga'

def resolve(valor_inicial, valor_actual):
    if (valor_actual == 1):
        return 1
    elif (valor_actual == 2):
        return 2
    else:
        for i in range(valor_actual - 1, 1 , -1):
            if (valor_inicial % i != 0):
                return resolve(valor_inicial,valor_actual - i)

if __name__ == "__main__":
    n = int(input())
    print(resolve(n,n))

v=int(input())
if v==1:
    print(1)
    exit(0)
elif v==2:
    print(2)
    exit(0)
for i in range(v-1,0,-1):
    if v%i!=0:
        print(v-i)
        break

a = int(input())
if(a==2):
    print(2)
else:
    print(1)

def play(v):
    if v>2:
        return 1
    else:
        return v

input = int(input())
print(play(input))

n = int(input())
if n == 2:
    print(2)
else:
    print(1)

n = int(input())

if( n == 2 ): print(2)
else: print(1)

n = int(input())
if n == 2:
    print("2")
else:
    print("1")

n=int(input())
if(n==1):
    print(1)
elif(n==2):
    print(2)
else:
    print(1)

n=int(input())
if(n==2):
    print(2)
else:
    print(1)

n=int(input())
if n==2:
    print("2")
else:
    print("1")

n = int(input())
if n > 2: print 1
else: print n

#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    from math import gcd
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """
        dict() -> new empty dictionary
        dict(mapping) -> new dictionary initialized from a mapping object's
            (key, value) pairs
        dict(iterable) -> new dictionary initialized as if via:
            d = {}
            for k, v in iterable:
                d[k] = v
        dict(**kwargs) -> new dictionary initialized with the name=value pairs
            in the keyword argument list.  For example:  dict(one=1, two=2)
        """
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    def gcd(x, y):
        """greatest common divisor of x and y"""
        while y:
            x, y = y, x % y
        return x

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    print(1 if int(input()) != 2 else 2)

if __name__ == '__main__':
    sync_with_stdio(False)
    main()

def game(n):
    if int(n) == 2:
        print(n)
    else:
        print(1)

w = input()
game(w)

n=int(input())
if(n==2):
	print(2)
else:
	print(1)

x=int(input())
if x!=2:
    print(1)
else:
    print(2)

n = int(input())

if (n == 1 or n == 2):
    print(n)
else:
    print(1)

n=int(input())
if n>2 or n==1:
	print("1")
elif n==2:
	print("2")

a = int(input())
if(a==2):
    print(2)
else:
    print(1)

def do():
    n = int(input())
    if  n == 1:
        print(1)
    elif n == 2:
        print(2)
    else:
        print(1)

do()

# cf 1081 A 800
n = int(input())
if n == 2:
    print(2)
else:
    print(1)

n = int(input())
if n==2:
	print(2)
else:print(1)

n = int(input())
if n == 2:
    print(2)
else:
    print(1)

# Contest: Avito Cool Challenge 2018 (https://codeforces.com/contest/1081)
# Problem: A: Definite Game (https://codeforces.com/contest/1081/problem/A)

def rint():
    return int(input())

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

print(1 if rint() != 2 else 2)

n=int(input())
if(n==2):
    print(n)
else:
    print(1)

print(1 if (int(input())) is not 2 else 2)

x = int(input())
if(x==2):print (2)
else: print(1)

if(int(input())==2):
	print(2)
else:
	print(1)

n = input()
if n == "2": print(2)
else: print(1)

n = int(input())

if n==2:
    print(2)
else:
    print(1)

t= int(input())
if t!=2:
    print("1")
else:
    print("2")

a=int(input())
if a==2:
  print("2")
else:
  print("1")

a = int(input())
if a == 2:
	print(2)
else:
	print(1)

v=int(input())
if v is 2:
    print(2)
else:
    print(1)

n=int(input())
if n!=2:
	print(1)
else:
	print(n)

a=int(input())
print(1 if a-1!=1 else a)

# You'll never get ahead of anyone as long as you try to get even with him. Lou Holtz
# by : Blue Edge - Create some chaos

v=int(input())
print(1 if v!=2 else 2)

n=int(input())
if n==2:print("2")
else:print("1")

def f(n):
    if n==2:
        return 2
    else:
        return 1
n=int(input())
print(f(n))

if int(input()) != 2:
    print(1)
else:
    print(2)

t=input()
if t!=2:
    print 1
else:
    print 2

n=int(input())
if n==1 or n==2:
	print(n)
else:
	print(1)

a=int(raw_input())
if a==2:
	print 2
else:
	print 1

n = int(input())
print(2 if n == 2 else 1)

import sys,math
from fractions import gcd
from collections import defaultdict
from io import BytesIO
import hashlib
sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#n,m = [int(x) for x in input().split(' ')]

if n > 2:
    print(1)
else:
    print(n)

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
n=int(input())
'''
a = map(int, raw_input().split())

i=n-1

base=0

print(n+1)

while i>=0 :
	a[i]+=base
	base+=((i-a[i]%n)+n)%n
	ans=((i-a[i]%n)+n)%n
	print('1'),
	print(i+1),
	print(ans)
	i-=1
print('2'),
print(n),
print(n)
'''
if n!=2:
	print(1)
else:
	print(2)

n = int(input())
if n!=2:
    print(1)
else:
    print(2)

x = int(input())

if x==2:
    print(x)
else:
    print(1)

n = int(input());
if n == 2:
	print(2);
else:
	print(1);

N = int(raw_input())
if N==2:
    print 2
else:
    print 1

n = int(input())
if n > 2:
    print("1")
else:
    print(n)

from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def solve():
    n=inp()
    if n<=2:
        print(n)
    else:
        print(1)
for _ in range(1):
    solve()

n = input()
if n==2:
    print 2
else:
    print 1

n=int(input())
if(n>2):
    print(n-1)
else:
    print(n)

import sys

pin = sys.stdin.readline
pout = sys.stdout.write

ran=range
n=int(pin())
print(1)

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  return 1

# main()
print(main())

n = int(input())

if n == 1:
	print(1)
else:
	if n % n-1 != 0:
		print(1)
	else:
		print(2)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

raw_input ()
print 1

v=int(input())
n=v;c=0
if v==1:
	print("1")
	exit()
else:
	for x in range(v-1,2,-1):
		if x%v!=0:
			print(x)
			c=x
			break
print(n-c)

n=int(input())
if n%2==0:
    print(n%3)
else:
    print(n%2)

n=int(input(""))
print(1)
if(n==2):
    print("2")

n=int(input())
if n!=2:
    print(2)
else:
    print(1)

v = int(input())
if v == 1:
    print(1)
else:
    print(v / (v - 1))

if (input() == 2):
    print('2')
else:
    print('1')

import random
import time

seed = int(time.time())
random.seed(seed)

def solve(v):
    return 1

def main():
    v = int(raw_input().strip())
    print solve(v)

if '__main__'==__name__:
    main()

def definateGame(n):
    no = n
    for i in range(2,no-1):
        if no%i !=0 and no > 1:
            no -= i
    return no

n = int(input())
print(definateGame(n))

x = int(input())
if(x==1):
          print(1)
else:
          print(x-1)

def func(a):
    if a==1:
        return 1
    elif a==2:
        return 2
    elif a%2==0 and a>3:
        return func(a-(a//3)*3)
    else:
        return func(a-(a//2)*2)
print(func(int(input())))

n=int(input())
for i in range(1,n+1):
    if n%i !=0:
       if n-i>0:
          n-=i
       else:
          break

print(n)

n=int(input())
s=n
l=[]
for i in range(1,n):
	if s%i!=0:
		s=s-i
		l.append(s)
		if s<1:
			print(l[-2])
			break
if n==1:
	print(n)

def main():
    v = int(input())
    print (1)

main()

n=int(input())
if n==1 or n==2:
	print(n)
else:
	print(n-1)

# https://codeforces.com/problemset/problem/1081/A
n = input()
print(1)

a = input()
if a == 2:print(2)
else:print(1)

def main():
    v = int(input())
    print(1)

main()

n = int(input())
print(n if n == 2 or n == 3 else 1)

def game(n):
    if n==1 or n==2:
        return n
    else:
        return 1

w = input()
print(game(w))

# cf 1081 A 800
n = int(input())
print(1)

#In the name of God
n = int(input())
print(1)

n = int(input())
if n == "2":
    print(2)
else:
    print(1)

n = input()

result = 2 if n == 2 else 1
print(result)

n=int(input())
for i in range(1,n+1):
    if n%i !=0:
       if n-i>=0:
          n-=i
       else:
          break

print(n)

def definateGame(n):
    no = n
    for i in range(2,no-1):
        if no%i !=0 and no > 1:
            no -= i
    return no

n = int(input())
definateGame(n)

# bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# from math import *
# from itertools import *
# import random
n = int(input())
v = n
if n == 1:
    print(n)
else:
    for i in range(2, n):
        if v % i != 0:
            if i > v:
                print(v)
                break
            else:
                v -= i
        else:
            continue

v = int(input())

if v != 2:
    print(1)
else:
    print(1)

def smallest_n(n):
    return 1

n = int(raw_input())
print(smallest_n(n))

if (input() == 2):
    print('2')
else:
    print('1')