#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4000 + 10;
const int MOD = 1e9 + 7;
int dp[MAXN][MAXN], N;
int main() {
  while (scanf("%d", &N) != EOF) {
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
      dp[i][0] = dp[i - 1][i - 1];
      for (int j = 1; j <= i; j++)
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % MOD;
    }
    cout << dp[N][N - 1] << endl;
  }
  return 0;
}
