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

public class baskerville_nv_BigInteger {
	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();
	}

	static BigInteger TWO = new BigInteger("2");
	void solve() throws IOException {
		int n = nextInt();
		BigInteger[] a = new BigInteger[n + 1];
		a[0] = a[1] = new BigInteger("1");
		BigInteger[][] C = new BigInteger[n + 1][n + 1];
		for (int i = 0; i < n; i++)
			C[i][i+1] = new BigInteger("0");
		for (int i = 0; i <= n; i++)
			C[i][0] = new BigInteger("1");
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= i; j++)
			{
				C[i][j] = C[i - 1][j - 1].add(C[i - 1][j]);
			}
		for (int i = 2; i <= n; i++) {
			a[i] = new BigInteger("0");
			for (int k = 1; k <= i; k++) {
				BigInteger tmp = a[i - k].multiply(C[i][k]).multiply(TWO.pow((i-k)*k));
				if (k % 2 == 1)
					a[i] = a[i].add(tmp);
				else
					a[i] = a[i].subtract(tmp);
			}
		}
		out.println(a[n].mod(BigInteger.valueOf(1000000007)));
	}

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