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

public class baskerville_dk_ml {
	BufferedReader br;
	PrintWriter out;
	StringTokenizer stok;

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

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

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

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

	char nextChar() throws IOException {
		return (char) (br.read());
	}

	String nextLine() throws IOException {
		return br.readLine();
	}

	final long MOD = (long) 1e9 + 7;

	void solve() throws IOException {
		int n = nextInt() + 1;
		long[][] c = new long[n][n];
		for (int i = 0; i < n; i++)
			c[i][0] = 1;
		for (int i = 1; i < n; i++) {
			for (int j = 1; j <= i; j++) {
				c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
			}
		}
		long[] p = new long[n * n + 1];
		p[0] = 1;
		for (int i = 1; i < n * n + 1; i++) {
			p[i] = p[i - 1] * 2 % MOD;
		}
		long[] a = new long[n];
		a[0] = 1;
		a[1] = 1;
		for (int i = 2; i < n; i++) {
			a[i] = 0;
			for (int j = 1; j <= i; j++) {
				long tmp = (a[i - j] * c[i][j]) % MOD;
				tmp = (tmp * p[(i - j) * j]) % MOD;
				a[i] += (j % 2 == 0 ? (MOD - tmp) : tmp);
			}
			a[i] %= MOD;
		}
		out.println(a[n-1]);
	}

	void run() throws IOException {
		br = new BufferedReader(new FileReader("baskerville.in"));
		out = new PrintWriter("baskerville.out");
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new baskerville_dk_ml().run();
	}
}
