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

public class baskerville_vd {
	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 long MOD = (long) 1e9 + 7;

	void solve() throws IOException {
		int n = nextInt();
		n++;
		long[] a = new long[n + 1];
		a[0] = a[1] = 1;
		long[] C = new long[n];
		long[] POW2 = new long[n + 1];
		POW2[0] = 1;
		for (int i = 1; i < n + 1; i++) {
			POW2[i] = POW2[i - 1] * 2 % MOD;
		}
		long[] curpow = new long[n + 1];
		Arrays.fill(curpow, 1);
		C[0] = C[1] = 1;
		 long tm = System.currentTimeMillis();
		for (int i = 2; i < n; i++) {
			long[] oldc = C.clone();
			C[0] = 1;
			for (int j = 1; j < i; j++) {
				C[j] = (oldc[j] + oldc[j - 1]) % MOD;
				curpow[j] = (curpow[j] * POW2[j]) % MOD;
			}
			C[i] = 1;

			for (int k = 1; k <= i; k++) {
				long tmp = (a[i - k] * C[k]) % MOD;
				tmp = (tmp * curpow[k]) % MOD;
				if (k % 2 == 1)
					a[i] = (a[i] + tmp);
				else
					a[i] = (a[i] - tmp + MOD);
			}
			a[i]%=MOD;
		}
		out.println(a[n - 1]);
		 System.err.println(System.currentTimeMillis() - tm);
	}

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