Let's write all the positive integer numbers one after another from 1 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...

Your task is to print the k-th digit of this sequence.

Input

The first and only line contains integer k (1 ≤ k ≤ 10000) — the position to process (1-based index).

Output

Print the k-th digit of the resulting infinite sequence.

Examples

Input


7


Output


7


Input


21


Output


5
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ar {

    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 (final 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 (final IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static boolean[] seen;
    static Map<Integer, Integer> map;
    static Map<Long,Long> lmap;
    static Set<Character> charset;
    static Set<Integer> set;
    static int[] arr;
    static int[][] dp;
    static int rem = (int) 1e9 + 7;
    static List<List<Integer>> graph;
    static int[][] kmv = { { 2, 1 }, { 1, 2 }, { 2, -1 }, { -1, 2 }, { -2, 1 }, { 1, -2 }, { -1, -2 }, { -2, -1 } };
    static char[] car;
    static boolean[] primes;
    static int MAX = (int) 1e4 + 1;
    static double[] dar;
    static long[] lar;

    static void Sieve() {
        primes = new boolean[MAX];
        primes[0] = true;
        primes[1] = true;
        for (int i = 2; i * i < MAX; i++) {
            if (!primes[i]) {
                for (int j = i * i; j < MAX; j += i) {
                    primes[j] = true;
                }
            }
        }
    }

    public static void main(String[] args) throws java.lang.Exception {
        FastReader scn = new FastReader();
    int n=scn.nextInt();
int ans=func(n);
System.out.print(ans);
        return;
    }
    static int func(int n){
    if(n<10)return n;

    int nod = 1;
    long numbers = 9;
    while(true)
    {
        if (n - nod * numbers >= 0) {
            n -= nod * numbers;
            // System.out.println(nod+" "+n+" "+numbers);
            nod++;
            numbers *= 10;
        } else
            break;
    }
    int i = (int) Math.pow(10, nod - 1);
    
    if (n == 0) {
        String s=""+(i-1);
        return s.charAt(s.length()-1)-'0';
    }
    
    while(true)
    {
        if (n - nod <= 0) {
            return ("" + i).charAt(n-1) - '0';
        }
        n -= nod;
        i++;
    }
    }
}