#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e11;
const long long mod = 1e9 + 7;
const long long N = 4040;
long long dp[2][N], dp2[2][N];
int main() {
  ios_base::sync_with_stdio(false);
  memset(dp, 0, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  long long n;
  cin >> n;
  dp[1][0] = dp[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    long long now = i % 2, prev = 1 - i % 2;
    for (long long j = 0; j < (N); ++j) {
      dp[now][j] = (j + 1) * dp[prev][j];
      if (j != 0) dp[now][j] += dp[prev][j - 1];
      dp[now][j] %= mod;
    }
  }
  dp2[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    long long now = i % 2, prev = 1 - i % 2;
    for (long long j = 0; j < (n + 1); ++j) {
      dp2[now][j] = (j)*dp2[prev][j];
      if (j != 0) dp2[now][j] += dp2[prev][j - 1];
      dp2[now][j] %= mod;
    }
  }
  long long sum = 0, x = n % 2;
  for (long long j = 0; j < (n + 1); ++j) sum += dp[x][j] - dp2[x][j];
  sum %= mod;
  sum += mod;
  sum %= mod;
  cout << sum << endl;
}
