#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

const long long MOD = 1e9 + 7;
long long tmp;
long long a[7777], pow2[7777], cpow[7777];
long long c[2][7777];
int f = 0, ff = 1;

int main()
{
    freopen("baskerville.in", "r", stdin);
    freopen("baskerville.out", "w", stdout);
    int n;
    cin >> n;
    n++;
    pow2[0] = a[0] = a[1] = 1;
    for (int i  = 1; i <= n; ++i)
        pow2[i] = (pow2[i - 1] << 1), pow2[i] %= MOD, cpow[i] = 1;
    c[1][0] = c[1][1] = cpow[0] = 1;
    for (int i = 2; i < n; ++i)
    {
        c[f][0] = 1;
        for (int j = 1; j < i; ++j)
            c[f][j] = (c[ff][j] + c[ff][j - 1]), c[f][j] = (c[f][j] > MOD ? c[f][j] - MOD : c[f][j]), cpow[j] *= pow2[j], cpow[j] %= MOD;
        c[f][i] = 1;

        for (int k = 1; k <= i; ++k)
        {
            tmp = (a[i - k] * c[f][k]), tmp %= MOD;
            tmp *= cpow[k], tmp %= MOD;
            a[i] += MOD;
            if (k & 1) a[i] += tmp; else a[i] -= tmp;
        }
        a[i] %= MOD;
        f = 1 - f, ff = 1 - ff;
    }    
    cout << a[n - 1] << "\n";
}
