https://www.acmicpc.net/problem/1790
def count(t):
num=1
for i in range(t):
num*=10
return num
n,k=map(int,input().split())
t=1
num=0
r=0
e=0
while 1:
max=(count(t)-count(t-1))*t
if num+max>=k:
k-=num
r=k//t
e=k%t
n-=r
break
num+=max
n-=count(t)-count(t-1)
t+=1
r+=count(t-1)-1
if n<0 or n==0 and e!=0: print("-1")
elif e==0:
m=str(r)
print(m[len(m)-1])
else:
r+=1
m=str(r)
print(m[e-1])