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 generator

		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}

		return array;
	}
	static void sort(String a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static String[] RA(String [] array){
		Random rgen = new Random();  // Random number generator

		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    String temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}

		return array;
	}
static long inverse(long x, long p)
    {
        return pow(x, p - 2, p);
    }
static boolean isPrime(long n)
{
    long h=(long)Math.sqrt(n);
    for(long i=2;i<=h;i++)
    if(n%i==0)
    return false;
    return true&&n!=1;
}
    static long gcd(long a,long b)
    {
        if(a<b)
        return gcd(b,a);
        else if(b==0)
        return a;
        else
        return gcd(b,a%b);
    }
    static long pow(long a,long b,long mod){
		if(b == 0)	return 1;
		long t = pow(a,b>>1,mod);
		t = (t * t) % mod;
		if((b & 1) == 1)	t = (t * a);
		if(t >= mod)	t %= mod;
		return t;
}
    static long pow(long a,long b){
		if(b == 0)	return 1;
		long t = pow(a,b>>1);
		t = (t * t);
		if((b & 1) == 1)	t = (t * a);
		return t;
}
    static void seive(int n,int prime[])//1 for prime -1 for not prime
    {
        for(int i=2;i<=n;i++)
            if(prime[i]==0)
            {
                prime[i]=1;
                for(int j=2;j*i<=n;j++)
                prime[j*i]=-1;
            }
    }
    static int max(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;

    }
    static long max(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;
    }
    static int min(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static long min(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static class Pair<T1,T2>
    {
        T1 x;T2 y;
        Pair(T1 xx,T2 yy)
        {
            x=xx;
            y=yy;
        }
    }

	static class Writer {
		private final PrintWriter p;
		Writer(OutputStream o) {
			p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(o)));
		}
		void p(Object... o1) {
			for (Object o11 : o1) {
				p.print(o11 + "" );
			}
		}
		<T>void pa(T a[])
		{
		    for(T i:a)
		    System.out.print(i+" ");
		    System.out.println();
		  }
		void p(String s) {
			p.print(s);
		}
		void pln(Object... o1) {
			p(o1);
			p.println();
		}
		void flush() {
			p.flush();
		}
		void close() {
			p.close();
		}
	}
    static class Reader {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;
		int flag=0;
		FileReader file;
		Reader()
		{
		  }
		  Reader(String x)throws IOException
		  {
		      flag=1;
		      file=new FileReader(x);
		  }
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);

				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		public String nl() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		public String n() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		public long nL() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		public int nI() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		public int[] NIA(int n) //nextINtArray
		{
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nI();
			}
			return arr;
		}
		public int[] NIA1(int n) //nextINtArray
		{
			int[] arr = new int[n+1];
			for (int i = 1; i <=n; i++) {
				arr[i] = nI();
			}
			return arr;
		}

		public long[] NLA(int n) //nextLongArray
		{
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nL();
			}
			return arr;
}
		public long[] NLA1(int n) //nextLongArray
		{
			long[] arr = new long[n+1];
			for (int i = 1; i <=n; i++) {
				arr[i] = nL();
			}
			return arr;
}
		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}
static class DSU
{
    int a[],size[],c=1,m;
    HashMap<String,Integer> hm=new HashMap<String,Integer>();
    DSU(int n)
    {
        a=new int[n+1];
        m=n;
        size=new int[n+1];
        for(int i=1;i<=n;i++)
    {
        a[i]=i;
        size[i]=1;
    }
    }
    void add(String x,int i)
    {
        hm.put(x,i);
    }
    int find(int n)
    {
        while(a[n]!=n)
        {
            a[n]=a[a[n]];
        n=a[n];
    }
        return n;
    }
    int[] eval()
    {
       int y[]=new int[m+1];
       for(int i=1;i<=m;i++)
       y[find(i)]++;
       return y;
    }
    void union(int a1,int b)
    {
        int x=find(a1);
        int y=find(b);
        if(size[x]>size[y])
    {
        a[y]=x;
        size[x]+=size[y];
    }
    else
    {
       a[x]=y;
       size[y]+=size[x];
    }
}
        //System.out.println(Arrays.toString(a));
}
class Segment
{
    int sum[];
    void build(int a[],int v,int l,int r)
    {
        if(l==r)
        sum[v]=a[l];
        else
        {
            int m=(l+r)/2;
            build(a,v*2,l,m);
            build(a,2*v+1,m+1,r);
            sum[v]=sum[v*2]+sum[2*v+1];
        }
    }
    void update(int a[],int l,int r,int x,int v,int y)
    {
        if(l==r&&r==y)
            sum[v]+=x;
        else if(l>y||y>r)
        return;
        else
        {
            int m=(l+r)/2;
            update(a,l,m,x,2*v,y);
            update(a,m+1,r,x,2*v+1,y);
            sum[v]=sum[2*v]+sum[2*v+1];
        }
    }
    int query(int v,int l,int r,int x,int y)
    {
        if(x>r||y<l)
        return 0;
        else if(x<=l&&r<=y)
        return sum[v];
        else
        {
            int m=(l+r)/2;
        return query(2*v,l,m,x,y)+query(2*v+1,m+1,r,x,y);
    }
}
}

static class Trie
  {
      Trie child[]=new Trie[26];
      int count=0;
    }
   /* void insert(String a)
    {
        Trie tmp=root;
        for(int i=0;i<a.length();i++)
        {
            int v=a.charAt(i)-'a';
            if(tmp.child[v]==null)
            {
                tmp.child[v]=new Trie();

            }
                tmp=tmp.child[v];
            }
            if(tmp.count==0)
            r++;
            tmp.count=1;
        }*/
    }
    class Pairs implements Comparable<Pairs>
    {
        int x,y;String z;
        Pairs(int a,int b)
        {
            x=a;y=b;
        }
        @Override
         public int compareTo(Pairs a)
            {

            if(a.x>this.x||(a.x==this.x&&a.y<this.y)||(a.x==this.x&&a.y==this.y&&(a.z).equals("BhayanakMaut")))
            return 1;
            else
            return -1;
        }
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Long.bitCount;

public class Main {

    public static void main(String[] args) {
        FastScanner in = new FastScanner();
        long []a = new long[16];
        a[0] = 0;
        for(int i=1; i<16; ++i)
            a[i] = a[i-1]+((9*(long)Math.pow(10, i-1))*i);
        long N = in.nextLong();
        int pos = 0;
        for(int i=0; i<16; ++i){
            if(N<=a[i]){
                pos = i;
                break;
            }
        }
        if(pos==1){
            System.out.println(N);
            System.exit(0);
        }
        long prev = a[pos-1];
        long curr = N;
        long rem = curr - prev;
        long ans = 0;
        for(int i=1; i<pos; ++i){
            ans = ans*10 + 9;
        }
        long g = (rem+(pos-1))/pos;
        long take = (rem+(pos-1))%pos;
        long number = ans + g;
        String str = Long.toString(number);
        System.out.println(str.charAt((int)take));
    }

    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.util.Scanner;

public class DigitsSequence {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);
        long k,c,n,d;
        c=1;
        d=9;
        n=1;
        k= sc.nextLong();
        while(k>(c*d)) {
            k-=(c*d);
            n*=10;
            d*=10;
            c++;
        }
        n+=(k-1)/c;
        char[] num = String.valueOf(n).toCharArray();
        System.out.println(num[(int)((k-1)%c)]);
    }

}


//package codeforces;
import java.util.*;
import java.math.BigInteger;
public class test_round_B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		BigInteger k=sc.nextBigInteger();

		BigInteger i=new BigInteger("0");
		int d=0;

		BigInteger a=new BigInteger("0");
		while(i.compareTo(k)!=1)
		{
			if(i.compareTo(k)==0)
			{
				break;
			}
			else
			{
				d++;
				BigInteger temp=new BigInteger("0");
				for(int j=0;j<d;j++)
				{
					temp=temp.multiply(new BigInteger("10")).add(new BigInteger("9"));
				}
				i=i.add(new BigInteger(Integer.toString(d)).multiply(temp.subtract(a)));
				//i=i+d*(temp-a);
				a=temp;
			}

		}

		//System.out.println(a) ;
		BigInteger b=a.divide(new BigInteger("10"));
		BigInteger t=b;
		BigInteger l=t;
		//System.out.println(b);
		int dig=0;

		if(b.equals(new BigInteger("0")))
		{
			dig=0;
		}
		else
		{
			while(b.compareTo(new BigInteger("0"))==1)
			{
				dig++;
				b=b.divide(new BigInteger("10"));
			}
		}

		//System.out.println(dig);
		int flag=dig+1;
		BigInteger num=new BigInteger("0");
		b=t;
		while(b.compareTo(new BigInteger("0"))==1)
		{
			//System.out.println("sun");
			BigInteger rev=b.divide(new BigInteger("10"));
			num=num.add(new BigInteger(Integer.toString(dig)).multiply(b.subtract(rev)));
			//num+=(b-rev)*dig;
			b=b.divide(new BigInteger("10"));
			dig--;

		}
		//System.out.println(num);
		//System.out.println(t);
		BigInteger net=k.subtract(num);
		BigInteger div=net.divide(new BigInteger(Integer.toString(flag)));
		int q;
		if(net.mod(new BigInteger(Integer.toString(flag))).equals(new BigInteger("0")))
		{
			//System.out.println("s");
			//System.out.println();
			q=0;
			t=t.add(div);
			System.out.println(t.mod(new BigInteger("10")));
		}
		else
		{
			//System.out.println(div);
			//System.out.println(flag);
			//System.out.println(net);
			BigInteger r=div.multiply(new BigInteger(Integer.toString(flag)));
			r=net.subtract(r);
			//q=Integer.toString(net%flag).length();

			//System.out.println(q);
			//System.out.println(t);
			//System.out.println(pig);
			//System.out.println(w);
			t=t.add(div.add(new BigInteger("1")));
			//System.out.println(r);
			l=t;
			int pig=0;
			while(t.compareTo(new BigInteger("0"))==1)
			{
				pig++;
				t=t.divide(new BigInteger("10"));
			}
			//System.out.println(pig);
			BigInteger p=new BigInteger(Integer.toString(pig));
			BigInteger rem=p.subtract(r);
			//System.out.println(l);
			while(rem.compareTo(new BigInteger("0"))==1)
			{
				l=l.divide(new BigInteger("10"));
				rem=rem.subtract(new BigInteger("1"));
			}
			//System.out.println(l);
			//System.out.println(r);
			//System.out.println(c);
			//int f=t/w;
			//System.out.println(f);
			System.out.println(l.mod(new BigInteger("10")));
		}

	}

}


    import java.util.Scanner;

    public class ABC {
        public static void main(String[] args){

            Scanner sc=new Scanner(System.in);
            long k,c,n,d;
            c=1;
            d=9;
            n=1;
            k= sc.nextLong();
            while(k>(c*d)) {
                k-=(c*d);
                n*=10;
                d*=10;
                c++;
            }
            n+=(k-1)/c;
            char[] num = String.valueOf(n).toCharArray();
            System.out.println(num[(int)((k-1)%c)]);
        }

    }


import java.util.*;
import java.io.*;
import java.util.stream.Collectors;

public class P1177A {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(r.readLine());
        if (n < 10) {
            System.out.print(n);
            return;
        }

        int len = 1;
        long edge = 10;
        long prev = 0;
        long prepow = 0;
        while (edge - 1 < n) {
            prepow = (long)Math.pow(10, len);
            long pow = prepow * 10;
            prev = edge;
            edge = edge + (pow - prepow) * (len + 1);
            len += 1;
        }

        long b = n - prev;
        long c = b / len;
        int rem = (int)(b % len);
        String s = Long.toString(prepow + c).charAt(rem) + "";

        System.out.print(s);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class DigitSeq {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException  e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {

		FastReader sc = new FastReader();
		OutputStream outputstream = System.out;
		PrintWriter out = new PrintWriter(outputstream);

		long n = sc.nextLong();
		long[] arr = new long[14];
		for(int i = 1; i <= 13; i++){
			arr[i] = (long)Math.pow(10, i)-(long)Math.pow(10, i-1);
		}
		long total = 0;
		for(int i = 1; i <= 13; i++){
			if(total+(long)i*arr[i]>=n){
				long ans = n-total;
				long rest = ans;
				if(ans%i!=0){
					ans /= i;
					ans++;
				} else {
					ans /= i;
				}
				ans += (long)Math.pow(10, i-1)-1;
				String str = Long.toString(ans);
				int ind = (rest%i==0) ? i-1 : (int)(rest%i)-1;
				out.println(str.charAt(ind));
				break;
			}
			total = total+(long)i*arr[i];
		}
		out.close();
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class DD {
    public static void main(String args[]) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        long k=Long.parseLong(br.readLine());
        long ans=9*(int)Math.pow(10,0);
        int c=0;
        long start=0;
        while(k>ans) {
            c++;
            start=ans;
            ans+=9*(long)Math.pow(10,c)*(c+1);

        }
        long ms=(k-start-1)%(c+1);
        long a=(long)Math.pow(10,c)+(k-start-1)/(c+1);
        System.out.println((a+"").charAt((int)ms));
    }
}


import java.util.*;
import java.io.*;
public class DigitSequence
{
    public static PrintWriter out;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer token = new StringTokenizer("");
        String temp[] = br.readLine().split(" ");
        long pos = Long.parseLong(temp[0]);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        if (pos<10)
        {
            out.println(pos);
        }
        else
        {
            out.println(findDigitSequence(pos));
        }
        out.close();
    }

    private static char findDigitSequence(long pos)
    {
        //long result = 0;
        long min = 0;
        long max = 9;
        long dig = 1;
        while (pos>max)
        {
            dig++;
            min = max+1;
            max=(long) (max+9*Math.pow(10, dig-1)*dig);
        }
        pos = pos-min;
        long num = (long) (pos/dig+Math.pow(10, dig-1));
        String st = String.valueOf(num);
        if (dig==1)
        {
            return st.charAt(0);
        }
        char result = st.charAt((int) (pos%dig));
        return result;
    }

}


import java.io.*;
import java.util.*;

public class digits {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long k = Long.parseLong(br.readLine());
        long temp = 9 * (int)Math.pow(10,0);
        int count = 0;
        long initial = 0;
        while(k > temp) {
            count++;
            initial = temp;
            temp += 9 * (long)Math.pow(10,count)*(count+1);
        }
        long index = (k-initial-1)%(count+1);
        long num = (long)Math.pow(10,count) + (k-initial-1)/(count+1);
        System.out.println((num+"").charAt((int)index));
    }
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
import java.lang.management.*;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.sqrt;
import static java.lang.Integer.signum;

@SuppressWarnings("unchecked")
public class P1177B {

  public void run() throws Exception {
    for (long k = nextLong() - 1, d = 1, dc = 9, sv = 1; true; k -= dc, d++, sv *= 10, dc = (sv * 10 - sv) * d) {
      if (k <= dc) {
        println(Long.toString(sv + k / d).charAt((int)(k % d)));
        break;
      }
    }
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P1177B().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
    long gct = 0, gcc = 0;
    for (GarbageCollectorMXBean garbageCollectorMXBean : ManagementFactory.getGarbageCollectorMXBeans()) {
      gct += garbageCollectorMXBean.getCollectionTime();
      gcc += garbageCollectorMXBean.getCollectionCount();
    }
    System.err.println("[GC time : " + gct + " ms, count = " + gcc + "]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void printsp(int [] a) { for (int i = 0, n = a.length; i < n; print(a[i] + " "), i++); }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) { // RANDOM shuffle
    Random r = new Random();
    for (int i = a.length - 1, j, t; i >= 0; j = r.nextInt(a.length), t = a[i], a[i] = a[j], a[j] = t, i--);
  }

  void shuffle(int [] a, int m) { // QUICK shuffle
    for (int i = 0, n = a.length, j = m % n, t; i < n; t = a[i], a[i] = a[j], a[j] = t, i++, j = (i * m) % n);
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(Object [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      Object t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  int [] sort(int [] a) {
    final int SHIFT = 16, MASK = (1 << SHIFT) - 1, SIZE = (1 << SHIFT) + 1;
    int n = a.length, ta [] = new int [n], ai [] = new int [SIZE];
    for (int i = 0; i < n; ai[(a[i] & MASK) + 1]++, i++);
    for (int i = 1; i < SIZE; ai[i] += ai[i - 1], i++);
    for (int i = 0; i < n; ta[ai[a[i] & MASK]++] = a[i], i++);
    int [] t = a; a = ta; ta = t;
    ai = new int [SIZE];
    for (int i = 0; i < n; ai[(a[i] >> SHIFT) + 1]++, i++);
    for (int i = 1; i < SIZE; ai[i] += ai[i - 1], i++);
    for (int i = 0; i < n; ta[ai[a[i] >> SHIFT]++] = a[i], i++);
    return ta;
  }

  void flush() {
    pw.flush();
  }

  void pause() {
    flush(); System.console().readLine();
  }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Cses {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		// int t = sc.nextInt();
		// while (t-- > 0) {
		long n = sc.nextLong();

		if (n < 10) {
			System.out.println(n);
			return;
		} else {
			long sum = 0;
			long cur = 9;
			long prev = 0;
			int count = 1;

			while (n > cur) {
				n -= cur ;
				sum += cur / count;
				prev = cur;
				cur = 9 * (count + 1) * (long)Math.pow(10, count);
				count ++;
			}

			sum = sum + (n / count);

			if (n % count == 0) {
				System.out.println(sum % 10);
			} else {
				sum++;
				n = n % count;
				String s = String.valueOf(sum);
				System.out.println(s.charAt((int)n - 1));
			}
			// }
		}
	}

	public static boolean isSafe(int[][] chess, int row, int col) {
		for (int i = row - 1, j = col; i >= 0; i--) {
			if (chess[i][j] == 1) {
				return false;
			}
		}

		for (int i = col - 1, j = row - 1; i >= 0 && j >= 0; i--, j--) {
			if (chess[i][j] == 1) {
				return false;
			}
		}

		for (int i = col - 1, j = row + 1; i >= 0 && j < chess.length; i--, j++) {
			if (chess[i][j] == 1) {
				return false;
			}
		}

		return true;
	}

	static String swap(String str, int i, int j) {
		char temp;
		char[] ch = str.toCharArray();
		temp = ch[i];
		ch[i] = ch[j];
		ch[j] = temp;

		return String.valueOf(ch);
	}

	static String rev(String str) {
		StringBuilder sb = new StringBuilder(str);
		for (int i = str.length() - 1; i >= 0; i--) {
			sb.append(str.charAt(i));
		}
		String s = sb.toString();
		return s;
	}

	static int swap(int a, int b) {
		return a;
	}

	static class pair {
		int first;
		int second;
		public pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	}

	public static long power(long a, long b) {
		long res = 1;
		while (b > 0) {
			if ((b & 1) != 0) {
				res = (res * a) % 1000000007;
			}
			a = (a * a) % 1000000007;
			b = b >> 1;
		}
		return res;
	}

	public static int pow(int a, int b) {
		int res = 1;
		while (b > 0) {
			if ((b & 1) != 0) {
				res = (res * a);
			}
			a = a * a;
			b = b >> 1;
		}
		return res;
	}

	public static String catoString(char[] ch) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ch.length; i++) {
			sb.append(ch[i]);
		}
		return sb.toString();
	}

	public static boolean isPrime(long n) {
		if (n < 2) return false;
		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0) return false;
		}
		return true;
	}

	public static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		long d = gcd(a, b);
		return (a * b) / d;
	}

	static boolean isPowerOfTwo(long n) {
		return (long)(Math.ceil(Math.log(n) / Math.log(2)))
		       == (long)(Math.floor(Math.log(n) / Math.log(2)));
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = " ";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class CodeForces {
    class Pair<K, V> {
        K first;
        V second;
        public Pair(K k, V v) {
            first = k;
            second = v;
        }
    }
    private boolean contain(int set, int i) {
        return (set & (1<<i)) > 0;
    }

    private static int gcd(int a, int b) {
        if (b == 0) return a;
        return gcd(b, a%b);
    }

    private long pow(long a, long p) {
        if (p == 0) return 1;
        long b = pow(a, p/2);
        b = b * b;
        if (p % 2 == 1) b *= a;
        return b % mod;
    }

    private static boolean isSame(double a, double b) {
        return Math.abs(a - b) < 1e-10;
    }

    private static void swapBoolean(boolean[] p, int i, int j) {
        boolean tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
    }

    private static void swap(int[] p, int i, int j) {
        int tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
    }
    private static int countOne(int a) {
        if (a == 0) return 0;
        return countOne(a & (a-1)) + 1;
    }

    private static int sdiv(int a, int b) {
        return (a +b -1) / b;
    }

    private int[] retran(int index) {
        int[] res = new int[2];
        res[0] = index / M;
        res[1] = index % M;
        return res;
    }

    private int tran(int x, int y) {
        return x * M + y;
    }

    private boolean inTable(int x, int y) {
        return x>=0 && x< N && y >= 0 && y < M;
    }

    int N;
    int R;
    int[][] C = new int[10][10];
    int M;
    int mod = 1_000_000_007;
    long IMPO;
    int ans;

    int[] dx = new int[]{1,0, -1, 0};
    int[] dy = new int[]{0, -1, 0, 1};
    Map<String, Boolean> dp = new HashMap<>();

    class Edge {
        int u;
        int v;
        int start;
        int duration;
        public Edge(int u, int v, int l, int d) {
            this.u = u;
            this.v = v;
            this.start = l;
            this.duration = d;
        }
    }
    List<List<Integer>> graph = new ArrayList<>();
    List<Edge> edges = new ArrayList<>();
    int[] parent;
    boolean[] visited;
    public void run(Scanner scanner) throws IOException {

        long k = scanner.nextLong();
        int len = 1;
        long number = 9;
        for (int i = 0; true; i++) {
            if (len * number < k) {
                k -= len * number;
                len ++;
                number *= 10;
            } else {
                break;
            }
        }

        number /= 9;
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= 9; i++) {
            if (len * number < k) {
                k -= len * number;
            } else {
                sb.append(i);
                break;
            }
        }

        for (int i = 1; i < len; i++) {
            number /= 10;
            for (int j = 0; j <= 9; j++) {
                if (len * number < k) {
                    k -= len * number;
                } else {
                    sb.append(j);
                    break;
                }
            }
        }
        System.out.println(sb.charAt((int) k - 1));
    }

    public static void main(String[] args) throws NumberFormatException, IOException {

//      String fileName = "C://Users/user/eclipse-workspace/algo/example.txt";
//      String outFile = "C://Users/user/eclipse-workspace/algo/example-out.txt";
//      String fileName = "C://Users/user/eclipse-workspace/algo/A-small-practice.in";
//      String outFile = "C://Users/user/eclipse-workspace/algo/A-small-out.txt";
//      String fileName = "C://Users/user/eclipse-workspace/algo/A-large-practice.in";
//      String outFile = "C://Users/user/eclipse-workspace/algo/A-large-out.txt";
//      String fileName = "/Users/mobike/IdeaProjects/algo/B-small-practice.in";
//      String outFile = "/Users/mobike/IdeaProjects/algo/B-small-out.txt";
//      String fileName = "/Users/mobike/IdeaProjects/algo/B-large-practice.in";
//      String outFile = "/Users/mobike/IdeaProjects/algo/B-large-out.txt";
//      String fileName = "C://Users/user/eclipse-workspace/algo/C-small-practice.in";
//      String outFile = "C://Users/user/eclipse-workspace/algo/C-small-out.txt";
//      String fileName = "C://Users/user/eclipse-workspace/algo/D-small-practice.in";
//      String outFile = "C://Users/user/eclipse-workspace/algo/D-small-out.txt";
//      String fileName = "C://Users/user/eclipse-workspace/algo/D-large-practice.in";
//      String outFile = "C://Users/user/eclipse-workspace/algo/D-large-out.txt";

        Scanner scanner = new Scanner(System.in);

//        int T = scanner.nextInt();
//        for (int i = 1; i <= T; i++) {
            CodeForces jam = new CodeForces();
            jam.run(scanner);
//        }
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;

public class B1177 {

	public static void main(String[] args) throws Exception {
//		BufferedReader br = new BufferedReader(new FileReader("F:/books/input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Long n = Long.parseLong(br.readLine());
		long[] p = new long[15];
		int i;
		p[0]=1;
		for(i=1;i<15;p[i]=p[i-1]*10,i++);
		for(i=1;i*p[i-1]*9L<n;n-=i*p[i-1]*9L,i++);
		n--;
		int v = (int) (n%i);
		n/=i;
		n+=p[i-1];
		String s = n.toString();
		System.out.println(s.charAt(v));
	}

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MAX_N = 1000010;
	static final int INF = 0x3f3f3f3f;
	static final int mod = 1000000007;

	public static void main(String[] args) throws IOException {
		initReader(System.in);

//		int T = nextInt();
//		for (int i = 1; i <= T; i++)
			solve();

		pw.flush();
	}

	/*******************************************************************************************************************************/

	public static void solve() throws IOException {
		while (hasNext()) {
			long n = nextLong() - 1;

			long k = 1, x = 9;
			while (n - k * x >= 0) {
				n -= k * x;
				k += 1;
				x *= 10;
			}

			if (n == 0)
				pw.println(1);
			else {
				long num = x / 9 + n / k;
				String s = String.valueOf(num);
				pw.println(s.charAt((int) (n % k)));
			}
		}
	}

	/*******************************************************************************************************************************/

	static BufferedReader reader;
	static StringTokenizer tokenizer;
	static PrintWriter pw;

	public static void initReader(InputStream input) throws IOException {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

//		reader = new BufferedReader(new FileReader("ate.in"));
//		tokenizer = new StringTokenizer("");
//		printWriter = new PrintWriter(new BufferedWriter(new FileWriter("ate.out")));
	}

	public static boolean hasNext() {
		try {
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
		} catch (Exception e) {
			return false;
		}
		return true;
	}

	public static String next() throws IOException {
		while (!tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public static String nextLine() {
		try {
			return reader.readLine();
		} catch (Exception e) {
			return null;
		}
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static char nextChar() throws IOException {
		return next().charAt(0);
	}

	static class Pair {
		char first;
		boolean second;

		public Pair(char first, boolean second) {
			// TODO Auto-generated constructor stub

			this.first = first;
			this.second = second;
		}

		@Override
		public String toString() {
			// TODO Auto-generated method stub
			return "(" + this.first + ", " + this.second + ")";
		}
	}
}


import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
  final int mod = 1000000007;
  final int maxn = -1;
  final double eps = 1e-9;

  long digits(long n){
    if(n == 0) return 0;
    int p = (int)Math.log10(n);
    return (p + 1) * (n - (long)Math.pow(10, p) + 1) + digits((long)Math.pow(10, p) - 1);
  }

  void solve(){
    // freopen("in");
    String s = "";
    long k = nextLong();
    long i = 1;
    long j = k;
    while(i < j){
      long m = (i + j) / 2;
      if(digits(m) < k){
        i = m + 1;
      }
      else{
        j = m;
      }
    }
    if(digits(i) >= k) --i;
    printf("%c\n", String.valueOf(i + 1).charAt((int)(k - digits(i) - 1)));
  }

  final double pi = Math.acos(-1.0);
  final long infl = 0x3f3f3f3f3f3f3f3fl;
  final int inf = 0x3f3f3f3f;
  final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

  boolean zero(double x){ return x < eps; }

  /** io **/
  PrintWriter out;
  BufferedReader reader;
  StringTokenizer tokens;

  Main(){
    long s = System.currentTimeMillis();
    tokens = new StringTokenizer("");
    reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
    out = new PrintWriter(System.out);
    Locale.setDefault(Locale.US);     // imprime double com ponto
    solve();
    out.close();
    debug("Time elapsed: %dms", System.currentTimeMillis() - s);
  }

  void freopen(String s){
    try{ reader = new BufferedReader(new InputStreamReader(new FileInputStream(s)), 1 << 15); }
    catch(FileNotFoundException e){ throw new RuntimeException(e); }
  }

  /** input -- supõe que não chegou no EOF **/
  int nextInt(){ return Integer.parseInt(next()); }
  long nextLong(){ return Long.parseLong(next()); }
  double nextDouble(){ return Double.parseDouble(next()); }

  String next(){ readTokens(); return tokens.nextToken(); }
  String nextLine(){ readTokens(); return tokens.nextToken("\n"); }

  boolean readTokens(){
    while(!tokens.hasMoreTokens()){             // lê os dados, ignorando linhas vazias
      try{
        String line = reader.readLine();
        if(line == null) return false;          // EOF
        tokens = new StringTokenizer(line);
      }
      catch(IOException e){ throw new RuntimeException(e); }
    }
    return true;
  }

  /** output **/
  void printf(String s, Object... o){ out.printf(s, o); }
  void debug(String s, Object... o){ if(!ONLINE_JUDGE) System.err.printf((char)27 + "[91m" + s + (char)27 + "[0m", o); }

  public static void main(String[] args){ new Main(); }
}


import java.util.Scanner;

public class prob1177b {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);
        long k,c,n,d;
        c=1;
        d=9;
        n=1;
        k= sc.nextLong();
        while(k>(c*d)) {
            k-=(c*d);
            n*=10;
            d*=10;
            c++;
        }
        n+=(k-1)/c;
        char[] num = String.valueOf(n).toCharArray();
        System.out.println(num[(int)((k-1)%c)]);
    }

}


import java.util.Scanner;

public class Digits_Sequence_Hard_Edition_Kamel {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		getResult(k);
		sc.close();
	}

	static void getResult(long k) {
		long val = 0;;
		long ten = 1;
		int i = 1;
		while(true) {
			val = 9l*ten*i;
			if(k<=val) {
				decompose(k, ten, i);
				System.exit(0);
			}
			else {
				k-=val;
				ten = ten*10l;
				i++;
			}
		}
	}

	static void decompose(long offset, long ten, int size) {
		long val = ten - 1 +(long) Math.ceil((double)offset/size);
		int digit = (int)(((offset%size))-1 + size)%size;

		String result = String.valueOf(val).substring(digit, digit+1);
		System.out.print(result);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long K = Long.valueOf(br.readLine());
        long n = 0;
        long k = 0; //len * Math.pow(10, len) * 0.9;
        long len = 0;
        while(true){
            len++;
            long preK = k;
            long preN = n;
            k += len * Math.pow(10, len) * 0.9;
            n += Math.pow(10, len) * 0.9;
            if(K < k) {
                k = preK;
                n = preN;
                break;
            }
        }
        long step = len - 1;
        while(true){
            while(k <= K){
                long preK = k;
                long preN = n;
                if(step == 0){
                    k += len;
                    n++;
                }else{
                    k += len * Math.pow(10, step) * 0.9;
                    n += Math.pow(10, step) * 0.9;
                }
                if(k == K || (k >= K && k - K < len)){
                    //System.out.println(k);
                    //System.out.println(n);
                    String nStr = Long.toString(n);
                    System.out.println(nStr.charAt(nStr.length() - (int)(k-K) - 1));
                    return;
                }
                if(K < k){
                    k = preK;
                    n = preN;
                    break;
                }
            }
            step--;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigitsSequenceHardEdition solver = new BDigitsSequenceHardEdition();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigitsSequenceHardEdition {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            long k = in.nextLong();
            long start = 1;
            long nDigit = 1;
            while (true) {
                long curr = start * 9 * nDigit;
                if (curr >= k) break;
                start *= 10;
                nDigit += 1;
                k -= curr;
            }
            if (k % nDigit == 0) {
                start += (k / nDigit - 1);
                out.println(start % 10);
            } else {
                long n = start + ((k / nDigit));
                int off = (int) (k % nDigit);
                out.println(Long.toString(n).charAt(off - 1));
            }
        }

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Reader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) {
            try {
                din = new DataInputStream(new FileInputStream(file_name));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public long nextLong() {
            long ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() {
            try {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }
}


import java.util.*;

public class Solution {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       long n = sc.nextLong();
       long itrIdx = 0;
       long itr = 0;
       long num = 0;
       while(itrIdx < n){
           itrIdx += (itr+1)*(Math.pow(10,itr+1) - Math.pow(10,itr));
           num+= (Math.pow(10,itr+1) - Math.pow(10,itr));
           itr++;
       }

        itrIdx -= itr*(Math.pow(10,itr)-Math.pow(10,itr-1));
        num -= (Math.pow(10,itr)-Math.pow(10,itr-1));
        long lastNum = num + ((n-itrIdx)/itr);
        long lastNumIndex = itrIdx + (itr* (lastNum-num));

        if(lastNumIndex == n){
            lastNumIndex = lastNumIndex-itr;
            lastNum -=1;
        }

        String nextNum = String.valueOf(lastNum+=1);
        System.out.println(nextNum.charAt((int) (n-lastNumIndex-1)));

    }
}


import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[]) {new Main().run();}

	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	void run(){
	    work();
	    out.flush();
	}
	void work() {
	    long r=in.nextLong();
	    long b=0;
	    for(;;b++){
	        long num=9*(long)Math.pow(10,(double)b)*(b+1);
	        if(r-num<=0){
	            break;
	        }
	        r-=num;
	    }
	    long base=(long)Math.pow(10,(double)b);
	    long c=(r-1)/(b+1);
	    int m=(int)((r-1)%(b+1));
	    base+=c;

	    String str=base+"";
	    out.println(str.charAt(m));
	}
}


import java.util.*;

public class Solution {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       long n = sc.nextLong();
       long itrIdx = 0;
       long itr = 0;
       long num = 0;
       while(itrIdx < n){
           itrIdx += (itr+1)*(Math.pow(10,itr+1) - Math.pow(10,itr));
           num+= (Math.pow(10,itr+1) - Math.pow(10,itr));
           itr++;
       }

        itrIdx -= itr*(Math.pow(10,itr)-Math.pow(10,itr-1));
        num -= (Math.pow(10,itr)-Math.pow(10,itr-1));
        long lastNum = num + ((n-itrIdx)/itr);
        long lastNumIndex = itrIdx + (itr* (lastNum-num));

        if(lastNumIndex == n){
            lastNumIndex = lastNumIndex-itr;
            lastNum -=1;
        }

        String nextNum = String.valueOf(lastNum+=1);
        System.out.println(nextNum.charAt((int) (n-lastNumIndex-1)));

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Berland{

	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new Berland().run();
	}

	public void run() throws NumberFormatException, IOException
	{
		BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
		long N = Long.parseLong(file.readLine());
		long[] cutoff = new long[13];
		cutoff[0] = 0;
		for(int i = 1;i<=12;i++)
		{
			cutoff[i] = cutoff[i-1] + (long)(9*Math.pow(10,i-1))*i;
		}
		int dig = -1;
		for(int i = 0;i<12;i++)
		{
			if(cutoff[i]>=N)
			{
				dig = i;
				break;
			}
		}
		long sub = N - cutoff[dig-1]-1;
		long num = (sub)/dig;
		long number = (long)Math.pow(10,dig-1)+num;
		int pos = (int)(sub % dig);
		System.out.println((number+"").charAt(pos));
	}
}


// package name;
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		long k = s.nextLong();

		long dp[] = new long[13];
		long x = 9; int i = 1;

		long ansx = 0; int ansi = 0;
		for(; i < 13; i++) {
			dp[i] = dp[i - 1] + x * i;
			x *= 10;
			if(k <= dp[i]) {
				ansx = x;
				ansi = i;
				break;
			}

			if(dp[i] > 1000000000000l) break;
		}

		if(ansi < 2) {
			System.out.println(k);
			return;
		}

		k -= dp[ansi - 1];

		//System.out.println(k);

		long st = (long)Math.pow(10, ansi - 1);

		long div = (k / ansi);
		if(k % ansi == 0) div--;

		k -= div * ansi;

		//System.out.println(k);
		System.out.println(findKthDigit(st + div, k));

	}

	private static Long findKthDigit(long xx, long k) {
		int z = (int) k;
		ArrayList<Long> arr = new ArrayList();
		while(xx > 0) {
			arr.add(xx % 10);
			xx /= 10;
		}
		return arr.get(arr.size() - z);
	}

}


import java.util.Scanner;

public class digits
{
	public static void main(String[] args)
	{
		long k = (new Scanner(System.in)).nextLong();

		//k = 56
		//League 1: 0 - 9
		//League 2: 10 - 99
		//League 3: 100 - 999..
		//System.out.println("k = "+k);
		long league = 1;
		long irrelevancy = 0;
		while(true)
		{
			irrelevancy += league * (Math.pow(10, league) - Math.pow(10, league-1));
			if(k > irrelevancy)
				league ++;
			//league = 1 : k = 56 > 9
			//league = 2 : k = 56 < 99
			//therefore league = 2
			else
				break;
		}
		//System.out.println("League = "+league);
		irrelevancy = 0;
		for(long i=1; i<league; i++)
			irrelevancy += i * (Math.pow(10, i) - Math.pow(10, i-1));

		//irrelevancy = 1 * (10^1 - 10^0) = 9

		long modified_k = k - irrelevancy;

		//modified_k = 56 - 9 = 47
		//System.out.println("modified k = "+ modified_k);
		long number = (long)(Math.pow(10, league-1)) - 1 + modified_k / league;
		//System.out.println("number = "+number);

		if(modified_k % league == 0)
			System.out.println(number % 10);
		else
		{
			number ++;
			long position_of_digit = (long)(modified_k % league);
			//System.out.println(position_of_digit);
			//number = 24
			//position_of_digit = 47 % 2 = 1
			System.out.println((Long.toString(number)).charAt((int)position_of_digit-1));
		}
	}

}


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            long k=Long.parseLong(br.readLine());
            long l=1,h=1000000000000l;
            long p[]=new long[13];
            for(int i=1;i<=12;i++)
            {
                  long ll=9*i;
                  p[i]=ll*(long)Math.pow(10,i-1);
                  p[i]+=p[i-1];
            }
            while(h-l>1)
            {
                  long mid=(l+h)/2;
                  long num=(long)(Math.log(mid)/Math.log(10));
                  long l1=p[(int)num]+(num+1)*(mid-(long)Math.pow(10,num));
                  long l2=p[(int)num]+(num+1)*(mid-(long)Math.pow(10,num)+1);
                  if(k<=l1)
                   h=mid;
                  else if(k>l2)
                   l=mid;
                  else
                  { l=mid; h=mid; }
            }

            if(h-l==1)
            {
                long num=(long)(Math.log(h)/Math.log(10));
                long l1=p[(int)num]+(num+1)*(h-(long)Math.pow(10,num));
                long l2=p[(int)num]+(num+1)*(h-(long)Math.pow(10,num)+1);
                if(k>l1 && k<=l2)
                { l=h; }
            }

            long n=(long)(Math.log(l)/Math.log(10));
            long u=p[(int)n]+(n+1)*(l-(long)Math.pow(10,n));
            k-=u;
            String ss=String.valueOf(l);
            //System.out.println(l+" "+k);
            System.out.println(ss.charAt((int)(k-1)));
      }
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

public class Tests {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long inputNum = 0;
		String finalResult = "";

		inputNum = scanner.nextLong();
		long upperLimitResult = 0;
		long lowerLimitResult = 0;
		int multiplier = 0;
		do {
			multiplier++;
			lowerLimitResult = upperLimitResult;
			upperLimitResult += 9 * Math.pow(10, multiplier - 1) * (multiplier);
		} while (inputNum > upperLimitResult);
		long remainderFromLowerRange = inputNum - lowerLimitResult;
		long repititions = 0;
		if (multiplier > 1)
			repititions = (remainderFromLowerRange - 1 > 0 ? remainderFromLowerRange - 1 : 0) / multiplier;
		long currentNumber = (long) (Math.pow(10, multiplier - 1) + repititions);
		remainderFromLowerRange = remainderFromLowerRange - repititions * multiplier;
		long digitIndex = remainderFromLowerRange < multiplier ? multiplier - remainderFromLowerRange
				: remainderFromLowerRange % multiplier;

		if (multiplier == 1) {
			finalResult = (remainderFromLowerRange % 10) + "";
		} else {
			int charToGet = (int) ((multiplier - 1) - digitIndex);
			finalResult = (currentNumber + "").charAt(charToGet) + "";
		}
		System.out.print(finalResult);
		scanner.close();
	}

}


import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            long k=input.nextLong();
            long v=9;
            long s=0;
            int x=1;
            while(true)
            {
                if(s+v*x>k)
                {
                    break;
                }
                s+=v*x;
                v*=10;
                x++;
            }
            if(s==k)
            {
                out.println(9);
            }
            else
            {
                long d=k-s;
                long u=d/x;
                long rem=d%x;
                long nu=(long)Math.pow(10,x-1);
                nu+=u;
                if(rem==0)
                {
                    nu--;
                    out.println(nu%10);
                }
                else
                {
                    String str=String.valueOf(nu);
                    out.println(str.charAt((int)(rem-1)));
                }
            }
        }
        out.close();
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt()
        {
            return Integer.parseInt(next());
        }
        long nextLong()
        {
            return Long.parseLong(next());
        }
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf1177b {

    public static void main(String[] args) throws IOException {
        long k = rl(), n = -1;
        for (long l = 0, r = k; l <= r; ) {
            long m = l + (r - l) / 2;
            if (f(m) < k) {
                n = m + 1;
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        k -= f(n - 1);
        char[] s = Long.toString(n).toCharArray();
        prln(s[(int) k - 1]);
        close();
    }

    static long f(long x) {
        if (x < 10) {
            return x;
        }
        long pow10 = 1, cnt = 1;
        while (x >= pow10 * 10) {
            pow10 *= 10;
            ++cnt;
        }
        return cnt * (x - pow10 + 1) + f(pow10 - 1);
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // graph util
    static List<List<Integer>> g(int n) {List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new ArrayList<>()); return g;}
    static List<Set<Integer>> sg(int n) {List<Set<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; ++i) g.add(new HashSet<>()); return g;}
    static void c(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v); g.get(v).add(u);}
    static void cto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).add(v);}
    static void dc(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v); g.get(v).remove(u);}
    static void dcto(List<? extends Collection<Integer>> g, int u, int v) {g.get(u).remove(v);}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    static List<List<Integer>> rg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<List<Integer>> rdg(int n, int m) throws IOException {List<List<Integer>> g = g(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdg(List<List<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1); return g;}
    static void rsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) c(g, rni() - 1, ni() - 1);}
    static List<Set<Integer>> rdsg(int n, int m) throws IOException {List<Set<Integer>> g = sg(n); for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1); return g;}
    static void rdsg(List<Set<Integer>> g, int m) throws IOException {for (int i = 0; i < m; ++i) cto(g, rni() - 1, ni() - 1);}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static void pryesno(boolean b) {prln(b ? "yes" : "no");};
    static void pryn(boolean b) {prln(b ? "Yes" : "No");}
    static void prYN(boolean b) {prln(b ? "YES" : "NO");}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}}


import java.util.Scanner;

public class P_1177B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long k = scan.nextLong();
		long k2 = k - 10;
		int cont = 1, pos;
		String out; //System.out.println(getString((int)k));

		if(k <= 9)
			System.out.println(k);
		else {
			cont++;
			while(k2 >= cont*(long)(Math.pow(10, cont)-Math.pow(10, cont-1))) {
				k2 -= cont*(long)(Math.pow(10, cont)-Math.pow(10, cont-1));
				cont++;
			}
			pos = (int)(k2%cont);
			k2 /= cont;
			k2 += (long)Math.pow(10, cont-1);
			out = String.valueOf(k2);
			System.out.println(out.charAt(pos));
		}
	}

	/*public static String getString(int number) {
		int contador = 1;
		String salida = "";
		while(salida.length() <= number) {
			salida += contador;
			contador++;
		}
		return salida.substring(0, number);
	}*/
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.prefs.BackingStoreException;

public class answertillD {
	static ArrayList<Integer>[] adjlist;
	static int[][] adjmatrix;
	static int[][] adjmatrix2;
	static boolean[] vis;
	static boolean[] intialvis;
	static boolean[] vis2;
	static int[] counter;
	static int V, E;
	static Stack<Integer> st;
	static ArrayList<Integer> arrylist;
	static boolean flag;
	static int[] dx = new int[] { 1, -1, 0, 0 };
	static int[] dy = new int[] { 0, 0, 1, -1 };
	static int[] Arr;
	static PrintWriter pw;

	public static long gcd(long u, long v) {
		if (u == 0)
			return v;
		return gcd(v % u, u);
	}

	public static int dfs(int u) {
		vis[u] = true;
		int a = 0;
		for (int v : adjlist[u])
			if (!vis[v])
				a += dfs(v);

		return 1 + a;
	}

	public static void dfs(int u, int num) {
		vis2[u] = true;
		counter[u] = num;
		for (int v : adjlist[u])
			if (!vis2[v])
				dfs(v, num);
	}
static long diff=Long.MAX_VALUE;
	static boolean check(long num, long k) {
		int n=(num+"").length()-1;
		long m=1;
		long sum=0;int i=1;
		while(n-->0)
		{
		sum+=9*m*(i++)	;
		m*=10;
		}
		sum+=(num-m)*i+1;
		if(sum<=k)
			diff=Math.min(diff, k-sum);
		return sum<=k;
	}

	static long bin(long k) {
		long left = 1;
		long right = k+1;
		long mid;
		long ans = 1;
		while (left <= right) {
			mid = (left + right) / 2;

			if (check(mid, k)) {
				ans = mid;
				left = mid + 1;

			} else
				right = mid - 1;
		}
		return ans;
	}

	public static long power(long x, int i) {
		long r = 1;
		while (i-- > 0) {
			if (r > 1e18 / x)
				return (long) (1e18 + 5);
			r = r * x;
		}
		return r;
	}

	static int m;

	static int calculate(int[] Arrs, int[] Arre, int index, boolean left, boolean targetleft) {
		int ans = 0;
		int n = m + 2;

		if (left) {
			ans = Arre[index - 1];
			if ((index != E + 1))
				ans += (targetleft) ? Arre[index - 1] : n - Arre[index - 1] - 1;

		} else {
			ans = n - Arrs[index - 1] - 1;
			if ((index != E + 1))
				ans += ((targetleft) ? Arrs[index - 1] : n - Arrs[index - 1] - 1);
		}
		return ans;
	}

	static int min = Integer.MAX_VALUE;

	static void backtrack(int[] Arrs, int[] Arre, int soFarMin, int index, boolean left) {
		if (index == E) {
			min = Math.min(min, soFarMin - 1);
			return;
		}

		int newmin1 = calculate(Arrs, Arre, index, left, left);
		int newmin2 = calculate(Arrs, Arre, index, left, !left);
		backtrack(Arrs, Arre, soFarMin + newmin1 + 1, index - 1, left);
		backtrack(Arrs, Arre, soFarMin + newmin2 + 1, index - 1, !left);

	}
	public static String add(String str1,String str2){
		Stack<String>st=new Stack<String>();
		int n=str1.length();
		int m=str2.length();
		int max=Math.max(n, m);
		int sum=0,carry=0;
		for(int i=0;i<max;i++){
			int num1=0,num2=0;
			if(n>=i)
			 num1 = Integer.parseInt(str1.charAt(n-i) + "");
			if(m>=i)
			 num2 = Integer.parseInt(str2.charAt(m-i) + "");
			int z = num1 + num2 + carry;
			if (z >= 10) {
				sum = z / 10;
				carry = z % 10;
			} else {
				sum = z;
				carry=0;
			}
			st.add(sum+"");
		}
		StringBuilder sb=new StringBuilder();
		while(!st.isEmpty()){
			sb.append(st.pop());
		}
		return sb+"";
	}
	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		long k=sc.nextLong();
		long bi=bin(k);
		String str=bi+"";
		System.out.println(str.charAt((int) diff));

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long st = 1, en = n, ans = 0, len = 0;
            while (st <= en) {
                long mid = (st + en) / 2;
                long have = 0;
                int curLen = Long.toString(mid).length();
                long bef = 0;
                for (int i = 1; i < curLen; i++) {
                    long cur = 0;
                    for (int j = 1; j <= i; j++) {
                        cur *= 10;
                        cur += 9;
                    }
                    have += i * (cur - bef);
                    bef = cur;
                }
                have += curLen * (mid - bef);
                if (have < n) {
                    ans = mid;
                    len = have;
                    st = mid + 1;
                } else
                    en = mid - 1;
            }
            String s = Long.toString(ans + 1);
            for (int i = 0; i < s.length(); i++) {
                if (len + i + 1 == n) {
                    out.print(s.charAt(i));
                    return;
                }
            }
        }

    }
}


import java.util.Scanner;

public class Training {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long index = in.nextLong();
        if (index < 10) {
            //one digit
            System.out.println(index);
        } else if (index < 190) {
            //two digits
            solve(2, index, 10, 10);

        } else if (index < 2890) {
            //three digits
            solve(3, index, 190, 100);

        } else if (index < 38890) {
            //four digits
            solve(4, index, 2890, 1000);

            //start changing ------------------------------------------------------------
        } else if (index < 488890) {
            //five digits
            solve(5, index, 38890, 10000);

        } else if (index < 5888890) {
            //six digits
            solve(6, index, 488890, 100000);

        } else if (index < 68888890) {
            //seven digits
            solve(7, index, 5888890, 1000000);

        } else if (index < 788888890) {
            //eight digits
            solve(8, index, 68888890, 10000000);

        } else if (index < 8888888890l) {
            //nign digits
            solve(9, index, 788888890, 100000000);

        } else if (index < 98888888890l) {
            //ten digits
            solve(10, index, 8888888890l, 1000000000);

        } else {
            solve(11, index, 98888888890l, 10000000000l);

        }

    }

    static void solve(int length, long index, long lastPoint, long num) {
        String s = "";
        num += (index - lastPoint) / length;
        s += num;
        int mod = (int) ((index - lastPoint) % length);
        System.out.println(s.charAt(mod));
    }

}


import java.util.*;
import java.io.*;

public class DigitSequenceA {
    public static void main(String[] args) throws IOException{
        FastReader in = new FastReader();
        double digit = in.nextDouble();
        double temp = digit;
        long[] seq = new long[13];
        for(int i = 1; i<13; i++){
            seq[i] = (9* (long)Math.pow(10,i-1)) * (i) +seq[i-1];
        }
        int power = 0;
        for(int i = 0; i< 13; i++){
            if(temp-seq[i] >0){
                continue;
            }
            else{
                power = i;
                break;
            }
        }
        long place = (long) Math.ceil(digit - seq[power-1]);
        place = (long)Math.ceil(place/power);
        if((digit - seq[power-1])%power>0){
            place++;
        }

        long num = (long) (place + Math.pow(10,power-1)-1);
        String num2 = Long.toString(num);
        long end =  seq[power-1] + place*power;
        long answer = (long)(power-(end - digit));
        //System.out.println("Digit is at the " + power + " power");
        //System.out.println("Digit is at the " + place + " number of the sequence");
        //System.out.println("Number is " + num);
        //System.out.println("Digit is at the " + answer+  " in that number");
        //System.out.println("Answer is " + num2.charAt((int)answer-1));
        System.out.println(num2.charAt((int)answer-1));

    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class DigitQueries {
    public static void main(String[] args) throws IOException {

        FastReader in = new FastReader();

        int q = 1;

        while (q-- > 0) {
            long k;
            k = in.nextLong();
            Query(k);
        }

    }

    static void Query(long k){
        long x=0;
        long sum=0;
        while(sum<k){
            sum+=9*Math.pow(10, x)*(x+1);
            if(sum>k){
                sum-=9*Math.pow(10, x)*(x+1);
                break;
            }
            x++;
        }

        long y = (k-sum);
        long last = 0;
        last = (long)Math.pow(10,x)+ (long)y/(x+1)-1;
        long z =y%(x+1);
        if(z!=0){
            last=(long)(last+1)/(long)Math.pow(10,x+1-z);
        }
        System.out.println(last%10);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(
                new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                 BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

}


import java.util.*;
import java.io.*;
import java.text.*;

public class Main {
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception {
        long K = nl();
        K--;
        int sz = 1;long pw = 1;
        while(K >= pw){
            long npw = pw*10;
            long dig = sz*(npw-pw);
            if(K >= dig){
                K -= dig;
                sz++;pw *= 10;
            }else break;
        }
        long num = pw+K/sz;
        int dig = sz-(int)(K%sz)-1;
        while(dig-->0)num /= 10;
        pn(num%10);
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    static void debug(Object... o){System.err.println(Arrays.deepToString(o));}
    final long IINF = (long)2e18;
    final int INF = (int)1e9+2;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = true, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = multipleTC? ni():1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int e, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
        int[][][] g = new int[n][][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
            if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.Scanner;
public class Test {
	public static int digit(long number){
		int i = 1;
		long exp = 1;
		while(number > i * 9 * exp){
			number -= i * 9 * exp;
			i++;
			exp *= 10;
		}
		return i;
	}
	public static int result(long number){
		int digit = digit(number);
		long exp = 1;
		for(int i = 0; i < (digit - 1); i++){
			number -= (i+1) * 9 * exp;
			exp *= 10;
		}
		long b = number / digit;
		int c = (int)(number % digit);
		if(c > 0){
			String d = Long.toString(exp + b);
			return d.charAt(c - 1) - '0';
		}
		else{
			String d = Long.toString(exp + b - 1);
			return d.charAt(d.length() - 1) - '0';
		}

	}
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		long k = input.nextLong();
		System.out.println(result(k));
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
{
     static class FastScanner {
        BufferedReader br;
        StringTokenizer stok;
        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String next() throws IOException {
            while (stok == null || !stok.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return null;
                }
                stok = new StringTokenizer(s);
            }
            return stok.nextToken();
        }
        int ni() throws IOException {
            return Integer.parseInt(next());
        }
        long nl() throws IOException {
            return Long.parseLong(next());
        }
        double nd() throws IOException {
            return Double.parseDouble(next());
        }
        char nc() throws IOException {
            return (char) (br.read());
        }
        String nextLine() throws IOException {
            return br.readLine();
        }

        int[] niArray(int n) throws IOException{
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        long[] nlArray(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nl();
            return a;
        }

        double[] ndArray(int n)throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++)
                a[i] = nd();
            return a;
        }
    }

	static long mod=Long.MAX_VALUE;
	static PrintWriter out=new PrintWriter(System.out);
	static FastScanner in = new FastScanner(System.in);
	public static void main (String[] args) throws java.lang.Exception
	{   int i,j;
		long flag,flag1,flag2,temp,temp2,temp1,count,counter,l;
		HashMap<Integer,Integer> hm=new HashMap<Integer,Integer>();
		/*
		    if(hm.containsKey(z))
		        hm.put(z,hm.get(z)+1);
		    else
		        hm.put(z,1);
		 */
        ArrayList<Integer> arr=new ArrayList<Integer>();
        HashSet<Integer> set=new HashSet<Integer>();
        PriorityQueue<Integer> pq=new PriorityQueue<Integer>();

       //for(i=1;i<200;i++)
       //{
        long k=in.nl();
		temp=9;l=1;temp2=0;
		while(true)
		{   if(k<=temp2+temp*l)
		        {k-=temp2;break;}
		    else
		    {   temp2+=temp*l;
		        temp*=10;
		        l++;
		    }
		}
		long z=((k-1)/l);
		//out.println(i+":- "+l+" "+((k-1)/l)+"  "+(k%l==0?l:k%l));
		long no=(long)Math.pow(10,(l-1))+z;
		//out.println(no);
		int index=(int)(k%l==0?l:k%l)-1;
		String p=Long.toString(no);
		//out.println(p+" "+index);
		out.println(p.charAt(index));
       //}
		out.close();
	}
	static long gcd(long a,long b)
	{   if(b==0)
	        return a;
	    return gcd(b,a%b);
	}
	static long exponent(long a,long n)
	{   long ans=1;
	    while(n!=0)
	    {   if(n%2==0)
	            ans=(ans*a)%mod;
	       a=(a*a)%mod;
	       n=n>>1;
	    }
	    return ans;
	}
	static int binarySearch(int a[], int item, int low, int high)
    {   if (high <= low)
            return (item > a[low])?  (low + 1): low;
        int mid = (low + high)/2;
        if(item == a[mid])
            return mid+1;
        if(item > a[mid])
            return binarySearch(a, item, mid+1, high);
        return binarySearch(a, item, low, mid-1);
    }
}


import java.util.Scanner;

public class cf_contest_1177_problem_B {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        long k = s.nextLong();
        if (k<=9)
            System.out.println(k);
        else
        {

            int c = 1;
            while(k>c*((Math.pow(10,c)) - Math.pow(10,c-1)))
            {
                k-=c*((Math.pow(10,c)) - Math.pow(10,c-1));
//                System.out.println(k + " hello " + c);
                c++;
            }
//            System.out.println("k is " + k);
            long mo = k%c;

//            System.out.println("mo is " + mo);
            k = k/c;

            if (mo == 0) {
                mo = c;
                k--;
            }
            mo--;
//            k = Math.max(k-1,0);
//            System.out.println("k/c is " + k);
            long j = (long) (Math.pow(10,c-1) + k);

            String j1 = "" + j;
//            System.out.println("j1 is " + j1);
//            System.out.println("final ans= " + j1.charAt((int)mo));
//            System.out.println();
            System.out.println(j1.charAt((int)mo));
        }

    }
}


import java.util.Scanner;

public class DigitalSequence {

    public static void print(String s) {
        System.out.println(s);
    }

    public static void main(String[] args) {
        long k = new Scanner(System.in).nextLong();
        long i = 1,t=0, c = 9,digits = 0,l=0,k2=k;
        while(t<k){
            l = t;
            t += i*c;
            i++;
            c*=10;
            digits++;
        }
        k = k-l;
        long lastNumber = (long)Math.pow(10,digits-1)-1;
        long p = k/digits,q=k%digits;
        long finalNumber =lastNumber+p;
        if(q!=0){
            finalNumber++;
        }
            k = k-digits*p;
            if(k<=0)
                k+=digits;
        String ans = ""+finalNumber;
        int index = (int)(k-1);
        print(""+ans.charAt(index));
    }
}