import java.io.*;
import java.util.*;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Stack;

public class Main
{
      @SuppressWarnings("unchecked")
      public static void main(String args[])throws IOException
    {
         Reader ob=new Reader();
        Writer out=new Writer(System.out);
        Random oo=new Random();
        long k=ob.nL(),ans=0,p=9,num=0;
        for(int i=1;i<18;i++)
        {
            if(num+i*p<k)
            {
                num+=i*p;p*=10;
                ans=0;
                for(int j=0;j<i;j++)
                ans=9+ans*10;
            }
            else
            {
                long left=k-num;
                long r=left/i;
                left-=r*i;
                ans+=r;
                if(left>0)
                {
                 String s=Long.toString(ans+1);
                
                out.pln(s.charAt((int)left-1));
            }
            else
            {
                
                String s=Long.toString(ans);
                
                out.pln(s.charAt(i-1-(int)left));
            }
                break;
            }
            
        }
out.flush();
}
static void sort(int a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static Pairs[] RA(Pairs [] array){
		Random rgen = new Random();  // Random number generator			
 
		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    Pairs temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
 
		return array;
	}
	
 public static int[] RA(int [] array){
		Random rgen = new Random();  // Random number generator			
 
		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
 
		return array;
	}
	static void sort(long a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static long[] RA(long [] array){
		Random rgen = new Random();  // Random number... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?