#include "bits/stdc++.h"
using namespace std;
int start[10],koyta[10];
void pre()
{
int i,store = 9,store1 = 10;
koyta[0] = 0;
for(i=1;i<=8;i++)
{
koyta[i] = store;
store*=10;
}
start[1] = 1;
for(i=2;i<=8;i++)
{
koyta[i]*=i;
koyta[i]+=koyta[i-1];
start[i] = store1;
store1*=10;
}
}
int main()
{
pre();
int n,i,sub,div,rem,num,mod=10;
while(scanf("%d",&n)==1)
{
for(i=1;i<=8;i++)
{
if(n<=koyta[i])
{
sub = n-koyta[i-1];
div = sub/i;
num = start[i]-1+div;
rem = sub%i;
if(rem)
{
sub = i-(sub%i);
num = num+1;
while(sub--)
{
num/=mod;
}
}
printf("%d\n",num%mod);
break;
}
}
}
return 0;
}