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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;
	static final Random rand = new Random(556668949239L);

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

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

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

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

	public void solve() throws IOException {
		long a, b;
		String s, s1;
		int n = nextInt(), k = 0;
		for (int i = 0; i < 2e7; i++) {
			a = i;
			b = a * a;
			s = String.valueOf(a);
			s1 = String.valueOf(b);
			if (s1.indexOf(s) == s1.length() - s.length()) {
				k++;
				if (k == n) {
					out.println(a);
					return;
				}
			}
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader("gold.in"));
			out = new PrintWriter("gold.out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}