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

public class salary_sp_slow implements Runnable {

	public static void main(String[] args) {
		new Thread(new salary_sp_slow()).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());
	}

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

	private static final String FILENAME = "salary";

	public void solve() throws IOException {
		int n = nextInt();
		for (int i = 1; ; i++) {
			String si3 = BigInteger.valueOf(i).pow(3).toString();
			if (si3.length() < n) {
				n -= si3.length();
			} else {
				out.println(si3.charAt(n - 1));
				return;
			}
		}
	}
}
