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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	static ArrayList<StringBuilder> ans = new ArrayList<StringBuilder>();

	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());
	}

	boolean check(StringBuilder s, int k) {
		StringBuilder qq = new StringBuilder(s);
		BigInteger a = new BigInteger(k + qq.reverse().toString());
		BigInteger b = a.multiply(a);
		b = b.subtract(a);
		StringBuilder q = new StringBuilder("1");
		for (int i = 0; i < s.length() + 1; i++)
			q.append("0");

		/*
		 * String t = s;// a.toString(); String r = b.toString(); return
		 * t.charAt(0) == r.charAt(r.length() - t.length());
		 */
		return b.mod(new BigInteger(q.toString())).compareTo(BigInteger.ZERO) == 0;
	}

	public void solve() throws IOException {
		int k = nextInt();
		ans.add(new StringBuilder("0"));
		ans.add(new StringBuilder("1"));
		ans.add(new StringBuilder("5"));
		ans.add(new StringBuilder("6"));

		while (ans.size() < k) {
			int n = ans.size();
			StringBuilder s1 = new StringBuilder(ans.get(n - 2).toString());
			StringBuilder s2 = new StringBuilder(ans.get(n - 1).toString());
			boolean f1 = false;
			boolean f2 = false;
			while (!(f1 && f2)) {
				f1 = false;
				f2 = false;
				for (int i = 1; i < 10; i++) {

					if (!f1 && check(s1, i)) {
						f1 = true;
						ans.add(s1.append(i));
						if (!f2 && check(s2, i)) {
							f2 = true;
							ans.add(s2.append(i));
							break;
						}
					}
					if (!f2 && check(s2, i)) {
						f2 = true;
						ans.add(s2.append(i));
						if (f1)
							break;
					}
				}
				if (!f1 && !f2) {
					s1.append(0);
					s2.append(0);
					continue;
				}
				if (!f1) {
					s1.append(0);
					s2 = new StringBuilder(ans.get(ans.size() - 1).toString());
				}
				if (!f2) {
					s2.append(0);
					s1 = new StringBuilder(ans.get(ans.size() - 1).toString());
				}
				if (ans.size() > k)
					break;
			}
		}
		//for (int i = 0; i < k; i++)
			out.println(/*(i + 1) + " " + */ans.get(k-1).reverse());

	}

	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);
		}
	}
}
