#include <bits/stdc++.h>
using namespace std;
void ratoneo() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n));
  int m = n * n;
  int cnt = 0;
  for (int mask = 0; mask < (1 << m); mask++) {
    for (int bit = 0; bit < m; bit++) {
      int r = bit / n;
      int c = bit % n;
      a[r][c] = (mask >> bit) & 1;
    }
    bool reflexive = true;
    for (int x = 0; x < n; x++) {
      if (a[x][x] == 0) reflexive = false;
    }
    if (reflexive) continue;
    bool symmetric = true;
    for (int x = 0; x < n; x++) {
      for (int y = x + 1; y < n; y++) {
        if (a[x][y] == 1 and a[y][x] == 0) symmetric = false;
        if (a[x][y] == 0 and a[y][x] == 1) symmetric = false;
      }
    }
    if (not symmetric) continue;
    bool transitive = true;
    for (int x = 0; x < n; x++) {
      for (int y = 0; y < n; y++) {
        for (int z = 0; z < n; z++) {
          if (a[x][y] == 1 and a[y][z] == 1 and a[x][z] == 0) {
            transitive = false;
          }
        }
      }
    }
    if (not transitive) continue;
    cnt += 1;
  }
  cout << cnt << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  const int mod = 1e9 + 7;
  const int N = 4e3 + 10;
  vector<vector<int> > dp(N, vector<int>(N, -1));
  function<int(int, int)> stirling2 = [&](int n, int k) {
    if (n == 0 and k == 0) return 1;
    if (n == 0 or k == 0) return 0;
    if (dp[n][k] != -1) return dp[n][k];
    int add1 = (1LL * k * stirling2(n - 1, k)) % mod;
    int add2 = stirling2(n - 1, k - 1);
    int ret = add1 + add2;
    if (ret >= mod) ret -= mod;
    return dp[n][k] = ret;
  };
  long long ans = 0;
  int n;
  cin >> n;
  for (int k = 1; k <= n; k++) {
    int add = (1LL * k * stirling2(n, k)) % mod;
    ans += add;
    if (ans >= mod) ans -= mod;
  }
  cout << ans << '\n';
  return (0);
}
