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

public class salary_sp implements Runnable {

	public static void main(String[] args) {
		new Thread(new salary_sp()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			br = new BufferedReader(new FileReader(FILENAME + ".in"));
			out = new PrintWriter(FILENAME + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;

	PrintWriter out;

	StringTokenizer st;

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

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

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

	void myAssert(boolean e, String s) {
		if (!e) {
			throw new Error("Assertion failure " + s);
		}
	}

	private static final String FILENAME = "salary";
	
	final long MAXN = (long) 1e18;

	public void solve() throws IOException {
		long n = nextLong();
		myAssert((1 <= n) && (n <= MAXN), "Wrong N");
		long i = 1;
		int len = 1;
		while (true) {
			long l = i;
			long r = 3 * i;
			while (r - l > 1) {
				long m = (l + r) / 2;
				int ml = BigInteger.valueOf(m).pow(3).toString().length();
				if (ml <= len) {
					l = m;
				} else {
					r = m;
				}
			}
			if ((r - i) * len < n) {
				n -= (r - i) * len;
			} else {
				long t = i + (n - 1) / len;
				n--;
				n %= len;
				out.println(BigInteger.valueOf(t).pow(3).toString().charAt((int) n));
				return;
			}
			i = r;
			len++;
		}
	}
}
