https://www.acmicpc.net/problem/1790
using System;
class Program
{
static long count(long t){
long num=1;
for(int i=0;i<t;i++){
num*=10;
}
return num;
}
static void Main() {
string[] s=Console.ReadLine().Split(' ');
long n=long.Parse(s[0]);
long k=long.Parse(s[1]);
int t=1;
long num=0;
long r=0;
long e=0;
while(true){
long 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++;
}
r+=count(t-1)-1;
if(n<0 || n==0 && e!=0) Console.Write("-1");
else if(e==0){
string m=r.ToString();
Console.Write("{0}",m[m.Length-1]);
}
else{
r+=1;
string m=r.ToString();
Console.Write("{0}",m[(int)e-1]);
}
}
}