#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double esp = 1e-6;
const int maxn = 4010;
const int mod = 1e9 + 7;
long long dp[maxn][maxn];
int main() {
  dp[0][0] = 1;
  for (int i = 1; i < maxn; i++) {
    dp[i][0] = dp[i - 1][i - 1] % mod;
    for (int j = 1; j < maxn; j++) {
      dp[i][j] = ((dp[i][j - 1] + dp[i - 1][j - 1]) % mod + mod) % mod;
    }
  }
  int n;
  while (~scanf("%d", &n)) {
    printf("%lld\n", dp[n][n - 1]);
  }
  return 0;
}
