K = int(input())

list0 = ['0']
list1 = ['1']
list2 = ['2']
list3 = ['3']
list4 = ['4']
list5 = ['5']
list6 = ['6']
list7 = ['7']
list8 = ['8']
list9 = ['9']

an = 0


def AAA(list0,list1,list2,list3,list4,list5,list6,list7,list8,list9):
    nlist0 = [0]*(len(list0)+len(list1))
    nlist1 = [0]*(len(list0)+len(list1)+len(list2))
    nlist2 = [0]*(len(list1)+len(list2)+len(list3))
    nlist3 = [0]*(len(list2)+len(list3)+len(list4))
    nlist4 = [0]*(len(list3)+len(list4)+len(list5))
    nlist5 = [0]*(len(list4)+len(list5)+len(list6))
    nlist6 = [0]*(len(list5)+len(list6)+len(list7))
    nlist7 = [0]*(len(list6)+len(list7)+len(list8))
    nlist8 = [0]*(len(list7)+len(list8)+len(list9))
    nlist9 = [0]*(len(list8)+len(list9))
    
    for i in range(len(list0)):
        nlist0[i] = '0' + list0[i]
    for j in range(len(list1)):
        nlist0[len(list0)+j] = '0' + list1[j]
        
        
    for i in range(len(list0)):
        nlist1[i] = '1' + list0[i]
    for j in range(len(list1)):
        nlist1[len(list0)+j] = '1' + list1[j]
    for k in range(len(list2)):
        nlist1[len(list0)+len(list1)+k] = '1' + list2[k]
        
    
    for i in range(len(list1)):
        nlist2[i] = '2' + list1[i]
    for j in range(len(list2)):
        nlist2[len(list1)+j] = '2' + list2[j]
    for k in range(len(list3)):
        nlist2[len(list1)+len(list2)+k] = '2' + list3[k]
        

    for i in range(len(list2)):
        nlist3[i] = '3' + list2[i]
    for j in range(len(list3)):
        nlist3[len(list2)+j] = '3' + list3[j]
    for k in range(len(list4)):
        nlist3[len(list2)+len(list3)+k] = '3' + list4[k]
    
    for i in range(len(list3)):
        nlist4[i] = '4' + list3[i]
    for j in range(len(list4)):
        nlist4[len(list3)+j] = '4' + list4[j]
    for k in range(len(list5)):
        nlist4[len(list3)+len(list4)+k] = '4' + list5[k]
    
    for i in range(len(list4)):
        nlist5[i] = '5' + list4[i]
    for j in range(len(list5)):
        nlist5[len(list4)+j] = '5' + list5[j]
    for k in range(len(list6)):
        nlist5[len(list4)+len(list5)+k] = '5' + list6[k]
    
    for i in range(len(list5)):
        nlist6[i] = '6' + list5[i]
    for j in range(len(list6)):
        nlist6[len(list5)+j] = '6' + list6[j]
    for k in range(len(list7)):
        nlist6[len(list5)+len(list6)+k] = '6' + list7[k]
    
    for i in range(len(list6)):
        nlist7[i] = '7' + list6[i]
    for j in range(len(list7)):
        nlist7[len(list6)+j] = '7' + list7[j]
    for k in range(len(list8)):
        nlist7[len(list6)+len(list7)+k] = '7' + list8[k]
    
    for i in range(len(list7)):
        nlist8[i] = '8' + list7[i]
    for j in range(len(list8)):
        nlist8[len(list7)+j] = '8' + list8[j]
    for k in range(len(list9)):
        nlist8[len(list7)+len(list8)+k] = '8' + list9[k]
    
    for i in range(len(list8)):
        nlist9[i] = '9' + list8[i]
    for j in range(len(list9)):
        nlist9[len(list8)+j] = '9' + list9[j]
        
    return(nlist0,nlist1,nlist2,nlist3,nlist4,nlist5,nlist6,nlist7,nlist8,nlist9)


while len(list1)+len(list2)+len(list3)+len(list4)+len(list5)+len(list6)+len(list7)+len(list8)+len(list9) < K:
    an = an + len(list1)+len(list2)+len(list3)+len(list4)+len(list5)+len(list6)+len(list7)+len(list8)+len(list9)
    list0,list1,list2,list3,list4,list5,list6,list7,list8,list9 = AAA(list0,list1,list2,list3,list4,list5,list6,list7,list8,list9)

nK = K - an
if len(list1) >= nK:
    ans = list1[nK-1]
    nK = 10**8
else:
    nK = nK - len(list1)

if len(list2) >= nK:
    ans = list2[nK-1]
    nK = 10**8
else:
    nK = nK - len(list2)

if len(list3) >= nK:
    ans = list3[nK-1]
    nK = 10**8
else:
    nK = nK - len(list3)

if len(list4) >= nK:
    ans = list4[nK-1]
    nK = 10**8
else:
    nK = nK - len(list4)

if len(list5) >= nK:
    ans = list5[nK-1]
    nK = 10**8
else:
    nK = nK - len(list5)

if len(list6) >= nK:
    ans = list6[nK-1]
    nK = 10**8
else:
    nK = nK - len(list6)
    
if len(list7) >= nK:
    ans = list7[nK-1]
    nK = 10**8
else:
    nK = nK - len(list7)

if len(list8) >= nK:
    ans = list8[nK-1]
    nK = 10**8
else:
    nK = nK - len(list8)

if len(list9) >= nK:
    ans = list9[nK-1]
    nK = 10**8
else:
    nK = nK - len(list9)
    
    
print(int(ans))

### FIXED CODE ###




K = int(input())

list0 = ['0']
list1 = ['1']
list2 = ['2']
list3 = ['3']
list4 = ['4']
list5 = ['5']
list6 = ['6']
list7 = ['7']
list8 = ['8']
list9 = ['9']

an = 0


def AAA(list0,list1,list2,list3,list4,list5,list6,list7,list8,list9):
    nlist0 = [0]*(len(list0)+len(list1))
    nlist1 = [0]*(len(list0)+len(list1)+len(list2))
    nlist2 = [0]*(len(list1)+len(list2)+len(list3))
    nlist3 = [0]*(len(list2)+len(list3)+len(list4))
    nlist4 = [0]*(len(list3)+len(list4)+len(list5))
    nlist5 = [0]*(len(list4)+len(list5)+len(list6))
    nlist6 = [0]*(len(list5)+len(list6)+len(list7))
    nlist7 = [0]*(len(list6)+len(list7)+len(list8))
    nlist8 = [0]*(len(list7)+len(list8)+len(list9))
    nlist9 = [0]*(len(list8)+len(list9))
    
    for i in range(len(list0)):
        nlist0[i] = '0' + list0[i]
    for j in range(len(list1)):
        nlist0[len(list0)+j] = '0' + list1[j]
        
        
    for i in range(len(list0)):
        nlist1[i] = '1' + list0[i]
    for j in range(len(list1)):
        nlist1[len(list0)+j] = '1' + list1[j]
    for k in range(len(list2)):
        nlist1[len(list0)+len(list1)+k] = '1' + list2[k]
        
    
    for i in range(len(list1)):
        nlist2[i] = '2' + list1[i]
    for j in range(len(list2)):
        nlist2[len(list1)+j] = '2' + list2[j]
    for k in range(len(list3)):
        nlist2[len(list1)+len(list2)+k] = '2' + list3[k]
        

    for i in range(len(list2)):
        nlist3[i] = '3' + list2[i]
    for j in range(len(list3)):
        nlist3[len(list2)+j] = '3' + list3[j]
    for k in range(len(list4)):
        nlist3[len(list2)+len(list3)+k] = '3' + list4[k]
    
    for i in range(len(list3)):
        nlist4[i] = '4' + list3[i]
    for j in range(len(list4)):
        nlist4[len(list3)+j] = '4' + list4[j]
    for k in range(len(list5)):
        nlist4[len(list3)+len(list4)+k] = '4' + list5[k]
    
    for i in range(len(list4)):
        nlist5[i] = '5' + list4[i]
    for j in range(len(list5)):
        nlist5[len(list4)+j] = '5' + list5[j]
    for k in range(len(list6)):
        nlist5[len(list4)+len(list5)+k] = '5' + list6[k]
    
    for i in range(len(list5)):
        nlist6[i] = '6' + list5[i]
    for j in range(len(list6)):
        nlist6[len(list5)+j] = '6' + list6[j]
    for k in range(len(list7)):
        nlist6[len(list5)+len(list6)+k] = '6' + list7[k]
    
    for i in range(len(list6)):
        nlist7[i] = '7' + list6[i]
    for j in range(len(list7)):
        nlist7[len(list6)+j] = '7' + list7[j]
    for k in range(len(list8)):
        nlist7[len(list6)+len(list7)+k] = '7' + list8[k]
    
    for i in range(len(list7)):
        nlist8[i] = '8' + list7[i]
    for j in range(len(list8)):
        nlist8[len(list7)+j] = '8' + list8[j]
    for k in range(len(list9)):
        nlist8[len(list7)+len(list8)+k] = '8' + list9[k]
    
    for i in range(len(list8)):
        nlist9[i] = '9' + list8[i]
    for j in range(len(list9)):
        nlist9[len(list8)+j] = '9' + list9[j]
        
    return(nlist0,nlist1,nlist2,nlist3,nlist4,nlist5,nlist6,nlist7,nlist8,nlist9)


while an + len(list1)+len(list2)+len(list3)+len(list4)+len(list5)+len(list6)+len(list7)+len(list8)+len(list9) < K:
    an = an + len(list1)+len(list2)+len(list3)+len(list4)+len(list5)+len(list6)+len(list7)+len(list8)+len(list9)
    list0,list1,list2,list3,list4,list5,list6,list7,list8,list9 = AAA(list0,list1,list2,list3,list4,list5,list6,list7,list8,list9)

nK = K - an
if len(list1) >= nK:
    ans = list1[nK-1]
    nK = 10**8
else:
    nK = nK - len(list1)

if len(list2) >= nK:
    ans = list2[nK-1]
    nK = 10**8
else:
    nK = nK - len(list2)

if len(list3) >= nK:
    ans = list3[nK-1]
    nK = 10**8
else:
    nK = nK - len(list3)

if len(list4) >= nK:
    ans = list4[nK-1]
    nK = 10**8
else:
    nK = nK - len(list4)

if len(list5) >= nK:
    ans = list5[nK-1]
    nK = 10**8
else:
    nK = nK - len(list5)

if len(list6) >= nK:
    ans = list6[nK-1]
    nK = 10**8
else:
    nK = nK - len(list6)
    
if len(list7) >= nK:
    ans = list7[nK-1]
    nK = 10**8
else:
    nK = nK - len(list7)

if len(list8) >= nK:
    ans = list8[nK-1]
    nK = 10**8
else:
    nK = nK - len(list8)

if len(list9) >= nK:
    ans = list9[nK-1]
    nK = 10**8
else:
    nK = nK - len(list9)
    
    
print(int(ans))